python, pyenv and recompiling to handle a 64bit issue? - python

I have pyenv, and i want to use python 3.4.1 against apache.
To that end, I have installed mod_wsgi 4.2.7
In compiling mod_wsgi, I get the following error:
Object_NextNotImplemented' can not be used when making a shared object; recompile with -fPIC
/root/.pyenv/versions/3.4.1/lib/libpython3.4m.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
apxs:Error: Command failed with rc=65536
.
make: *** [src/server/mod_wsgi.la] Error 1
According to this page the issue is something to do with a 64bit or a 32 bit or... I don't know.
Anyway, the solution is to re-compile python with some sort of flag.
How do i resolve this issue, bearing in mind that i am using pyenv?

This is not the solution, i still get the same error after having done this
PYTHON_CONFIGURE_OPTS="--enable-unicode=ucs4 --enable-shared"
pyenv uninstall 3.4.1
pyenv install 3.4.1
so the first line - i didn't think would actually work, I don't know what it is doing. I guess it is just setting some magic system variable somewhere? Oh well, it is doing that.
I don't know what the unicode bit does - this was all suggested in this link here.
Becuase i am wanting to use python 3.4.1, and because it already exists, i then uninstall python 3.4.1
Then i reinstall python 3.4.1
If you wanted to do the same with python x.y.z, you would similarly have
PYTHON_CONFIGURE_OPTS="--enable-unicode=ucs4 --enable-shared"
pyenv uninstall x.y.z
pyenv install x.y.z
If you had not installed x.y.z python earlier, um, then you wouldn't need to uninstall it.
This whole installation process takes... a while. I started writing this answer right after i kicked off the install command, and it only recently finished.
On finishing i get
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
Installed Python-3.4.1 to /root/.pyenv/versions/3.4.1
But i don't know if that is bad or good. The prompt itself doesn't seem to know either, what with all those question marks around.

Related

Scrapy seems to have installed, but when checking for version I get "No module named scrapy"

I have the dependencies installed (openssl, lxml, pyopenssl, twisted matrix, etc...) and when I type in the command
easy_install Scrapy
it seems to work, and gives me this output
Searching for scrapy
Best match: scrapy 0.24.2
Processing scrapy-0.24.2-py2.7.egg
scrapy 0.24.2 is already the active version in easy-install.pth
Installing scrapy script to C:\Users\Joel\AppData\Local\Enthought\Canopy\User\Sc
ripts
Installing scrapy.bat script to C:\Users\Joel\AppData\Local\Enthought\Canopy\Use
r\Scripts
Using c:\users\joel\appdata\local\enthought\canopy\user\lib\site-packages\scrapy
-0.24.2-py2.7.egg
Processing dependencies for scrapy
Finished processing dependencies for scrapy
however, when I check the version of scrapy it gives me this error
C:\python27\python.exe: No module named scrapy
how do I install scrapy? I would like to scrape the web...
EDIT: when using
pip install scrapy
i get this error
************************************************************************
WARNING:
An optional code optimization (C extension) could not be compiled.
Optimizations for this package will not be available!
()
Could not find Visual Studio 2008 in your path.
If you do not have Visual Studio 2008 installed, you can use
the MinGW compiler instead. To install mingw, do:
enpkg mingw
To use the MinGW compiler to build an extension module, use
the '-c' flag, e.g.:
python setup.py build_ext -c mingw64
Note that building Python extensions with MinGW is not officially
supported, although it is known to work in many cases.
****************************************************************************
I have installed visual studio 2008 so maybe my path isnt pointing there? if so what do I need to add as an environmental variable so it sees it?
It seems possible, since you appear to have loaded the Enthought distribution, that the easy_install you ran used a different Python from the one you get when you use the "python" command (i.e one runs the Enthought distribution, one runs your system-installed Python, which eceryone except Alex gaynor should leave strictly alone). You should be able to check this with which easy_install and which python commands.
If they do appear to be related to the same Python executable I am a little at a loss.
Are you sure you have all of the correct dependencies?
Environment variables
OpenSSL
Visual C++
Check this link and let us know how you are checking the version and what errors you are getting.
http://doc.scrapy.org/en/latest/intro/install.html#intro-install-platform-notes
It looks like you are installing to the correct version of Python, but you can always try
easy_install-2.7 scrapy

NVM fails to install any version of Node.js in Cygwin

I've already learned that Node.js opted out of supporting Cygwin in the newer version, but NVM can't install the older version either. The error I'm getting:
$ nvm install v0.4.12
Additional options while compiling:
######################################################################## 100.0%
C:\Python27\python.exe: can't open file '/home/wvxvw/.nvm/src/node-v0.4.12/tools\
/waf-light': [Errno 2] No such file or directory
nvm: install v0.4.12 failed!
(formatted for readability)
I think this is because of Python binaries aren't aware of Cygwin-style path (and cannot find /home/ directory) I tried building from sources (same version) and am facing the same problem). I'm not sure however what to do. I wouldn't like to change Python installed in Windows for Python that can be installed through Cygwin. And if this error isn't just the tip of the iceberg, I'd maybe just change the Makefile.
The question is directed to those who might tell whether it makes sense to try to "fix" the Makefile, or should I just use Cygwin's version of Python (its problem is very buggy fork, but I think I could live with that...)
Command is not correct , use version without v. Try : nvm install 0.4.12

Unable to load mod_wsgi: Symbol not found: __Py_FalseStruct

I'm trying to install mod_wsgi (3.4) on my mac (mountain lion), I followed all the instructions here: http://code.google.com/p/modwsgi/wiki/InstallationInstructions but I'm unable to load that module due to the following error:
httpd: Syntax error on line 119 of /private/etc/apache2/httpd.conf: Cannot load /usr/libexec/apache2/mod_wsgi.so into server: dlopen(/usr/libexec/apache2/mod_wsgi.so, 10): Symbol not found: __Py_FalseStruct\n Referenced from: /usr/libexec/apache2/mod_wsgi.so\n Expected in: flat namespace\n in /usr/libexec/apache2/mod_wsgi.so
the message above is displayed by testing apache modules with:
apachectl -M
I have the default python mac install (2.7) plus the latest 3.3 manually installed using the dedicated dmg, when I ran ./configure I tried by specifying both versions and adding the flag --disable-framework (which honestly I don't know what it does, but I found it mentioned in other discussions).
I'm stuck... what should I do?
UPDATE:
I configured mod_wsgi (with default python 2.7) by running:
make distclean
./configure
make
sudo make install
anyway I would like to use python 3.3, and fix the error I reported above
mod_wsgi is a pain to install if you don't really know the bits and pieces that go along with it. At a guess, I'd say it has something to do with shared python libraries .Can I recommend using the homebrew package manager instead?
It's fairly straight forward installing brew, but installing mod_wsgi isn't anymore.
brew tap homebrew/apache
brew install mod_wsgi
Then follow the instructions after it completes. You'll have to change the directory where mod_wsgi is installed to.
A warning about homebrew though, you need to make sure you've got the latest version of XCode installed, or at least the xcode command line tools. Homebrew is great though.

Cannot easy_install readline for Python 2.7.3 on Mac Os Lion

I am trying to install the python readline module. I have already installed readline via homebrew.
If I type
easy_install readline
I get
Downloading http://pypi.python.org/packages/source/r/readline/readline-6.2.2.tar.gz#md5=ad9d4a5a3af37d31daf36ea917b08c77
Processing readline-6.2.2.tar.gz
Writing /var/folders/44/dhrdb5sx53s243j4w03063vh0000gn/T/easy_install-64FbG8/readline-6.2.2/setup.cfg
Running readline-6.2.2/setup.py -q bdist_egg --dist-dir /var/folders/44/dhrdb5sx53s243j4w03063vh0000gn/T/easy_install-64FbG8/readline-6.2.2/egg-dist-tmp-NOmStB
clang: error: no such file or directory: 'readline/libreadline.a'
clang: error: no such file or directory: 'readline/libhistory.a'
error: Setup script exited with error: command '/usr/bin/clang' failed with exit status 1
Any ideas about how I could fix this ?
Thanks
There is a new solution to this problem in Pypi, pip install gnureadline.
https://pypi.python.org/pypi/gnureadline
The root issue is libedit (BSD-licensed) vs. Gnu Readline (GPL-licensed) . Apple would rather provide incompatible BSD code, than provide compatible code that has GPL restrictions.
This bug should be fixed in readline version 6.2.4 released last week.
Also note that you do not need to install the readline library itself via homebrew. It is already included within the python readline module.
Anyone having problems with the python-readline module is welcome to open an issue on the GitHub page of the module. This will ensure that the problem is permanently solved for everyone.
I had this same problem in OS X Lion 10.8, and fixed it by renaming my /Developer to /Developer-old. See this issue.
None of the above worked from me.
After uninstall ipython and readline, I ran the following that finally worked
easy_install http://pypi.python.org/packages/source/r/readline/readline-6.1.0.tar.gz
pip install ipython
And yes, readline 6.1.0 is an old one, but 6.2.x or other would not work (in sept 2013).
Try installing the binary egg directly:
$ easy_install http://pypi.python.org/packages/2.7/r/readline/readline-6.2.2-py2.7-macosx-10.7-intel.egg#md5=25383d860632d4a1521961ba68a52fe2
Make sure you have gcc installed.
which gcc
should return
/usr/bin/gcc
I was getting the same error when trying to easy_install readline. It wasn't until I downloaded the tar and tried to manually build it that I noticed it said
checking whether make sets $(MAKE)... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/Users/roneill/readline-6.2.4.1/rl/readline-lib':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
that I realized what the actual problem was. I had not used this particular laptop in a while and had not used Xcode to install the command line tools. Once I did, things worked properly.

Homebrew failing to install postgresql; python 64-bit errors

I'm getting errors when running
$ brew install postgresql
==> Downloading http://ftp.postgresql.org/pub/source/v9.1.2/postgresql-9.1.2.tar.bz2
File already downloaded in /Users/neil/Library/Caches/Homebrew
Warning: Detected a framework Python that does not have 64-bit support in:
/Library/Frameworks/Python.framework/Versions/Current/Python
e configure script seems to prefer this version of Python over any others,
you may experience linker problems as described in:
http://osdir.com/ml/pgsql-general/2009-09/msg00160.html
fix this issue, you may need to either delete the version of Python
own above, or move it out of the way before brewing PostgreSQL.
te that a framework Python in /Library/Frameworks/Python.framework is
e "MacPython" version, and not the system-provided version which is in:
/System/Library/Frameworks/Python.framework
==> ./configure --disable-debug --prefix=/usr/local/Cellar/postgresql/9.1.2 --datadir=/usr/local/Cellar/postgresql/9.1.2/shar
^C
Here's where python is located.
$ which python
/usr/local/bin/python
I modified my ~/.zshrc PATH from
export PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
to
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
And although I'm getting python 64-bit errors, my version of python is 64-bit according to this SO post:
$ python -c 'import struct;print( 8 * struct.calcsize("P"))'
64
The problem pointed out in the referenced mailing list post is that the configure step isn't impacted by the PATH here. There's a whole other mechanism used to find things to link against; see Where do I set DYLD_LIBRARY_PATH on Mac OS X for a quick intro. You could try the suggested workaround given by the brew script--rename /Library/Frameworks/Python.framework/Versions/Current/Python to something else to get it out of the linker's search path, repeat the brew install, then put it back.
If you don't need Python bindings in your PostgreSQL, you can also just install it without Python bindings using brew install postgresql --no-python.
This command is installing the server, not the python bindings. Is that what you want? There is a installer for osx that will install the server for you.
Once you have done that, you can install the psycopg2 bindings directly from source.

Categories