My ultimate goal is to download and install awscli
http://docs.aws.amazon.com/cli/latest/userguide/awscli-install-linux.html
Seems python and pip are required in order to accomplish my goal.
Installing python via yum isn't working for me, so I downloaded and installed python3 manually as follows:
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
tar xf Python-3.6.1.tar.xz
cd Python-3.6.1.tar.xz
./configure
make
sudo make altinstall
When I do
pip3.6 --version
I get this:
Traceback (most recent call last):
File "/usr/local/bin/pip3.6", line 7, in <module>
from pip import main
ImportError: cannot import name 'main'
Environment:
RHEL 6.6
Accessed via ssh
What is going on? How to install pip and python3.6 correctly on my linux box?
Edit:
When trying to install via yum it fails so I am trying to avoid using yum:
[asemani#rcdc9pfda5r Python-3.6.1]$ sudo yum -y install python-pip
[sudo] password for asemeani:
Loaded plugins: security
Setting up Install Process
No package python-pip available.
Error: Nothing to do
Another Edit:
After importing sys and then called sys.path this is what I get:
[asemani#rcdc9pfda5r Python-3.6.1]$ python3.6
Python 3.6.1 (default, Apr 28 2017, 11:03:27)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/local/lib/python36.zip', '/usr/local/lib/python3.6', '/usr/local/lib/python3.6/lib-dynload', '/usr/local/lib/python3.6/site-packages']
>>> quit()
[asemani#rcdc9pfda5r Python-3.6.1]$ ls -l /usr/local/lib/python3.6/site-packages
total 32
-rw------- 1 root root 126 Apr 27 23:45 easy_install.py
drwx------ 11 root root 4096 Apr 27 23:45 pip
drwx------ 2 root root 4096 Apr 27 23:45 pip-9.0.1.dist-info
drwx------ 5 root root 4096 Apr 27 23:45 pkg_resources
drwx------ 2 root root 4096 Apr 27 23:45 __pycache__
-rw-r--r-- 1 root root 119 Apr 27 23:45 README.txt
drwx------ 5 root root 4096 Apr 27 23:45 setuptools
drwx------ 2 root root 4096 Apr 27 23:45 setuptools-28.8.0.dist-info
You need to edit the pip3 file like so (your path could be different):
nano /Library/Frameworks/Python.framework/Versions/3.6/bin/pip3
And change the import main line so it says:
from pip._internal import main
After this change, my pip3 started to work and I am on macOS. If you are using Linux, your path could be something like /usr/bin/pip3
I found this tip and more information from this thread:
https://github.com/pypa/pip/issues/5240
Don't invoke pip/pip3 directly, which are shortcuts at different locations for different user and they are not well maintained when you upgrade pip (check 'which pip' and 'sudo which pip').
$ sudo python -m pip install xxx #for python2
$ sudo python3 -m pip install xxx #for python3
These commands do not take shortcuts and directly invoke pip module, which is maintained very well (also works on Windows)
My OS is Linux Mint 18
sudo nano /usr/bin/pip3
Change
from pip import main
To
from pip._internal import main
sudo chmod -R a+rx /usr/local/lib/python3.6/site-packages
You can see the problem right there in your ls -l /usr/local/lib/python3.6/site-packages output that your pip directory is only readable by the owner, which is root.
Do a cd /usr/bin
Then sudo nano pip so as to edit the pip file
Change from pip import main to from pip._internal import main
This will resolve the issue
try the following as a way around the issue until it got solved
sudo python -m pip --version
>> pip 10.0.1 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)
sudo python -m pip install numpy --upgrade
>> Requirement already up-to-date: numpy in /usr/local/lib/python2.7/site-packages (1.14.2)
I don't exactly know the answer, but: that error indicates that the script can find some package called pip, but not the right one. Probably, an old version of pip, from back before they created a main method (you can check pip.__version__ from the python shell).
I'm willing to bet that you still have another, older version of python installed which has its own version of pip. For some reason your pythonpath is loading that one instead of the one that goes with py3.6.
Some possibilities to look into:
I don't know anything about redhat, but is there some redhat-specific way of choosing the "default python" to be used?
Is the shebang line at the top of the pip script something like #!/usr/bin/env python instead of #!/usr/bin/python3.6 like it should be?
Is it possible to modify your shell's PATH so that the downloaded python is used?
Is it possible to change your PYTHONPATH (i think it gets added to the default value of sys.path inside python; look it up) so that it loads the new pip instead of the old pip?
My OS was Mac sierra and I had to change the following line
from pip import main
into
from pip._internal import main
Seems the get pip script was missing the fact that more than 1 version of python could reside on a machine. So I added the following lines:
PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3
For some reason it was missing this. Anyway this worked for me. Thanks for your help guys.
Do the following steps to solve the problem --(Ubuntu-Debian)
step 1 - Go to directory
cd usr/bin/
and open pip3 file using gedit or nano(via terminal) .
Step 2- change from pip import main into from pip._internal import main
P.S - If you donot have permission to change use command - sudo chmod 777 pip3 and save this file.
Hope this helps!!
Related
Hy,
Sorry if this question was asked before, but I really couldnt find any helpful answer.
Running any python script in cygwin-terminal that uses modules that werent installed using cygwin-setup will just quit the python script without any output. Whats wrong?
Example:
import websocket
print "Done";
gives me a blank line and returns to the shell. Whereas
#import websocket
print "Done";
prints
Done
python scripts using i.e.
import hmac, base64, hashlib, urllib, urllib2, time, gzip, json, io, types, datetime, os
work fine.
I have:
-Cygwin64 on Win7-64bit using the mintty-terminal
-installed all python27 packages i found useful using setup.exe -> python is working
-i did run ez_setup.py under cygwin:
Installed /usr/lib/python2.7/site-packages/setuptools-2.1-py2.7.egg
Processing dependencies for setuptools==2.1
Finished processing dependencies for setuptools==2.1
-did run get-pip.py:
Requirement already up-to-date: pip in /usr/lib/python2.7/site-packages/pip-1.5-py2.7.egg
Cleaning up...
I have a copy of python27 on c:\python27 too. not using cygwin, but windows-cmd and using that python executable the above script works.
I need cygwin because i want to use curses and ansi codes etc but not use a virtual ubuntu or stuff.
I have:
$ ls -l python*
lrwxrwxrwx 1 Administrator None 13 18. Jan 11:12 python -> python2.7.exe
lrwxrwxrwx 1 Administrator None 13 18. Jan 11:12 python2 -> python2.7.exe
-rwxr-xr-x 1 Administrator None 7187 3. Okt 05:39 python2.7.exe
-rwxr-xr-x 1 Administrator None 1669 3. Okt 05:39 python2.7-config
lrwxrwxrwx 1 Administrator None 16 18. Jan 11:12 python2-config -> python2.7-config
lrwxrwxrwx 1 Administrator None 16 18. Jan 11:12 python-config -> python2.7-config
also running
pip
gives me a blank line and back comes the shell. whereas running pip in windows-cmd under c:\python27\scripts\ gives me:
Usage:
....
but running easy_install works:
$ easy_install
error: No urls, filenames, or requirements specified (see --help)
Thanks!
I had exactly the same problem. pip and pip2 run in the same way : no answer, even with only --version or --help option. pip3 does a core dump.
I found a hugly work around : remove cygwin64 and go back to cygwin.
If it could be helpful....
And it seems it has something to do with this issue https://github.com/pypa/pip/issues/1448
I'm relatively new to running Python with virtualenv so this might be an easy fix, but I can't for the life of me figure out what's going on. I'm running Windows 7 professional x64 with Python 2.7.5 installed I have installed pip and virtualenv. I have a django project that I'm attempting to work on which I have cloned from a Heroku repository. When I attempt to set up a virtualenv and install the requirements of my project I'm running into a strange error that I can't figure out. I have everything setup as follows:
Django project is placed in C:\Users\xxx\PythonProjects\myProject
I open a command prompt, cd to the myProject folder and execute the following command:
C:\Users\xxx\PythonProjects\myProject> virtualenv --no-site-packages env
This should create a nice clean virtual environment for my project, so I go ahead and activate as follows:
C:\Users\xxx\PythonProjects\myProject> Scripts\activate
The prompt changes to indicate my virtualenv has become active so I double check by "where"ing python and pip:
(env) C:\Users\xxx\PythonProjects\myProject> where python
C:\Users\xxx\PythonProjects\myProject\env\Scripts\python.exe
C:\Python27\python.exe
(env) C:\Users\xxx\PythonProjects\myProject>where pip
C:\Users\xxx\PythonProjects\myProject\env\Scripts\pip.exe
C:\Python27\Scripts\pip.exe
Since it looks like virtualenv is functioning correctly I next attempt to pip the requirements file as follows:
(env) C:\Users\xxx\PythonProjects\myProject> pip install -r requirements.txt
pip appears to run successfully installing all the packages I need. However when I load up python the following happens (django is one of the packages in my requirements file):
(env) C:\Users\xxx\PythonProjects\myProject>python
Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django
I then cd to the site-packages folder to find out what is going on and get the following:
(env) C:\Users\xxx\PythonProjects\myProject\Lib\site-packages>dir
Volume in drive C is Windows7_OS
Volume Serial Number is 808F-577A
Directory of C:\Users\xxx\PythonProjects\myProject\env\Lib\site-packages
07/17/2013 02:16 PM <DIR> .
07/17/2013 02:16 PM <DIR> ..
07/17/2013 02:16 PM 237 easy-install.pth
07/17/2013 02:16 PM <DIR> pip-1.3.1-py2.7.egg
07/15/2013 09:16 PM 332,005 setuptools-0.6c11-py2.7.egg
07/17/2013 02:16 PM 31 setuptools.pth
3 File(s) 332,273 bytes
3 Dir(s) 169,869,336,576 bytes free
It appears that my pip call failed to install ANYTHING into my site-packages folder, so python has no idea where to find my required packages. Instead they appear to all be located in C:\Users\xxx\PythonProjects\myProject\env\build
If I use pip install foo without a requirements file, then everything works fine and the foo ends up in my site-packages folder. Is there a way I can get this working with the requirements file, or am I going to have to manually install every package every time when using virtualenv? Sorry for the likely overly long post, but I wanted to make sure that all relevant information is here. Thanks for the help!
Edit with additional information:
It appears that my requirements file may be the source of the problem. Only about half of the packages are being downloaded, the last being django-polymorphic. The lines in my requirements file that specify that package and the following package are as follows:
django-polymorphic==0.4.2
-e hg+https://bitbucket.org/fcurella/django-profiles#5c982ce7c040351fca9847a85dd4ff29f8a367e6#egg=django_profiles-dev
django-sekizai==0.7
-e git://github.com/divio/django-shop.git#0fb2258d27332166e3f76ad7cf7335c1f0a389b2#egg=django_shop-dev
-e git://github.com/fivethreeo/django-shop-categories.git#345fb100f5f680e6ac2066f74f25515eb2cd9374#egg=django_shop_categories-dev`
So I figured out the answer to my own question.
Basically, if you are running Python 2.7 (and likely other versions) on Windows, some packages don't play nicely. If anyone else is having this problem, you should download Windows binaries from http://www.lfd.uci.edu/~gohlke/pythonlibs/ and remove those packages from your requirements.txt file. Once I did so, pip stopped crashing during the install process and correctly installed the rest of the packages in my requirements.txt file.
The packages I needed were:
pillow
psycopg
reportlab
I recently uninstalled postgresql and installed pyscopg2 via pip.
I know there's some trickery involved with libcrypto and libssl
Currently i have them symlinked to:
$ ls -lah libssl.*
-rwxr-xr-x 1 root wheel 402K Aug 28 11:06 libssl.0.9.7.dylib
-rwxr-xr-x 1 root wheel 589K Aug 28 11:06 libssl.0.9.8.dylib
lrwxr-xr-x 1 root wheel 55B Nov 29 23:38 libssl.1.0.0.dylib -> /usr/local/Cellar/openssl/1.0.1c/lib/libssl.1.0.0.dylib
lrwxr-xr-x 1 root wheel 55B Nov 30 02:25 libssl.dylib -> /usr/local/Cellar/openssl/1.0.1c/lib/libssl.1.0.0.dylib
/usr/lib
$ ls -lah libcrypto.*
-rwxr-xr-x 1 root wheel 2.1M Aug 28 11:06 libcrypto.0.9.7.dylib
-rwxr-xr-x 1 root wheel 2.6M Aug 28 11:06 libcrypto.0.9.8.dylib
-r-xr-xr-x 1 root wheel 1.6M Oct 31 22:12 libcrypto.1.0.0.dylib
lrwxr-xr-x 1 root wheel 58B Nov 30 02:27 libcrypto.dylib -> /usr/local/Cellar/openssl/1.0.1c/lib/libcrypto.1.0.0.dylib
whereby I installed openssl via ports
Now when I run arc diff, I am getting the infamous
$ arc diff
dyld: Library not loaded: /usr/lib/libpq.5.dylib
Referenced from: /usr/bin/php
Reason: image not found
Trace/BPT trap: 5
There are a few answers here in SO which talks about symlinking these libs to the postgresql install directory. Obviously, this won't work for me.
What should I do?
Turns out /usr/lib/libpq.5.dylib was absent but /usr/lib/libpq.5.4.dylib was not.
sudo ln -s /usr/lib/libpq.5.4.dylib /usr/lib/libpq.5.dylib
fixed the issue.
just use the below commands in your terminal
(use the proper postgresql version)
$ brew unlink postgresql#14
$ brew link libpq --force
https://github.com/opentable/otj-pg-embedded/issues/152#issuecomment-954348544
I got the error
Library not loaded: '/usr/local/opt/postgresql/lib/libpq.5.dylib'
Reason: tried: '/usr/local/opt/postgresql/lib/libpq.5.dylib' (no such file), '/usr/local/lib/libpq.5.dylib' (no such file), '/usr/lib/libpq.5.dylib' (no such file)
when running a Django project and to fix it I had to uninstall the pip packages:
pip uninstall psycopg2
pip uninstall psycopg2-binary
and then install them again:
pip install psycopg2
pip install psycopg2-binary
And this made the project run without the error.
Not unlike #Pablo Marambio, I fixed this issue by adding the following line to ~/.profile:
export DYLD_LIBRARY_PATH=/Library/PostgreSQL/9.3/lib:$DYLD_LIBRARY_PATH
For Postgres.app v9.3.5.0 (presumably others too) I added the following line instead:
export DYLD_LIBRARY_PATH=/Applications/Postgres.app/Contents/Versions/9.3/lib:$DYLD_LIBRARY_PATH
Then, of course, run source ~/.profile
To resolve this, I had to uninstall postgresql and then install again.
$ brew uninstall postgresql
$ brew update
$ brew install postgres
I had to do this for postgresql 14 + brew
sudo ln -s /opt/homebrew/opt/postgresql#14/lib/postgresql#14/libpq.5.dylib /opt/homebrew/opt/postgresql/lib/libpq.5.dylib
I'm using poetry so to solve it on my fastapi project, I had to do this to fix it:
poetry remove psycopg2
poetry add psycopg2
It try to load libpq.5.dylib from the symlink /opt/homebrew/opt/postgresql/lib/libpq.5.dylib but found not file, so you need to update it:
# TODO: get this from the error, after "Library not loaded:"
SYMLINK_PATH="/usr/lib/libpq.5.dylib"
# TODO: find this in your machine. The version maybe different than mine
DESTINATION_PATH="/opt/homebrew/opt/postgresql/lib/postgresql#14/libpq.5.dylib"
sudo mv $SYMLINK_PATH $SYMLINK_PATH.old
sudo ln -s $DESTINATION_PATH $SYMLINK_PATH
I'm using debian with a default python installation of 2.6
I wanted to migrate to python 2.7, including installing easy_install.
I followed someone else's instruction to delete my /usr/bin/python, then link
ln -s /usr/bin/python2.7 /usr/bin/python
I downloaded the most recent version of setuptools
and cd'ed to the file. The install help asked me to run it as a shell program, I did, with the following error:
sh setuptools-0.6c11-py2.7.egg
Traceback (most recent call last):
File "<string>", line 1 in <module>
ImportError: No Module named setuptools.command.easy_install
I have a feeling that my installation of easy_install is related to the version of python I'm running, but I can't quite figure it out. I tried also downloading the .tar.gz file, cd-ing into the directory, and running
python setup.py build; setup.py install
After I run that, I can use easy_install, with the following error:
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No Module named pkg_resources
Can anyone suggest to me a solution? Thanks for the help.
Replacing the system Python isn't a great idea. Moving up by one point release
probably won't break your system, but who wants to take the risk? Installing
libraries to your system Python using easy_install can also lead to problems
if they conflict with each other.
An alternative is to build Python from source, install it to your home
directory, and use virtualenv to create isolated environments into which you can
install whatever libraries you need for a given project using pip (which is
the more modern equivalent to easy_install).
For Python 2.7, if you want some of the 'optional' parts of the standard
library, that means building a couple of other things, too. Here's a script
(largely cobbled together from blog posts scattered across the interweb) that
works for me on Debian "Squeeze" (stable, at the time of writing):
#!/bin/bash -e
# Setup
sudo aptitude install build-essential
mkdir -p ${HOME}/.local
mkdir build-python
cd build-python
# Get sources
### Tcl/Tk <http://www.tcl.tk/software/tcltk/download.html>
wget "http://downloads.sourceforge.net/project/tcl/Tcl/8.5.13/tcl8.5.13-src.tar.gz"
wget "http://downloads.sourceforge.net/project/tcl/Tcl/8.5.13/tk8.5.13-src.tar.gz"
### Berkeley DB <http://www.oracle.com/technetwork/products/berkeleydb/downloads/index-082944.html>
wget "http://download.oracle.com/berkeley-db/db-4.8.30.tar.gz"
### Python <http://www.python.org/download/>
wget "http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz"
# Build Tcl
tar xzf tcl8.5.13-src.tar.gz
cd tcl8.5.13/unix
./configure --prefix=${HOME}/.local
make
make install
cd ../..
# Build Tk
tar xzf tk8.5.13-src.tar.gz
cd tk8.5.13/unix
./configure --prefix=${HOME}/.local
make
make install
cd ../..
# Build Berkeley DB 4.8
tar xzf db-4.8.30.tar.gz
cd db-4.8.30/build_unix
../dist/configure --prefix=${HOME}/.local/opt/BerkeleyDB.4.8 --enable-tcl --with-tcl=${HOME}/.local/lib
make
make install
cd ../..
# Set compile flags
export LDFLAGS="-L${HOME}/.local/lib -L${HOME}/.local/opt/BerkeleyDB.4.8/lib"
export CPPFLAGS="-I${HOME}/.local/include -I${HOME}/.local/opt/BerkeleyDB.4.8/include"
export CXXFLAGS=${CPPFLAGS}
export CFLAGS=${CPPFLAGS}
export LD_LIBRARY_PATH=${HOME}/.local/lib:${HOME}/.local/opt/BerkeleyDB.4.8/lib
export LD_RUN_PATH=${LD_LIBRARY_PATH}
# Build Python 2.7
tar xzf Python-2.7.3.tgz
cd Python-2.7.3
./configure --prefix=${HOME}/.local
make
make altinstall
cd ..
# Install virtualenv, pip and virtualenvwrapper
curl http://python-distribute.org/distribute_setup.py | ${HOME}/.local/bin/python2.7
curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | ${HOME}/.local/bin/python2.7
${HOME}/.local/bin/pip install virtualenvwrapper
# Update ~/.bashrc
echo 'export PATH="${HOME}/.local/bin:${PATH}"' >> ${HOME}/.bashrc
echo 'export WORKON_HOME="${HOME}/.local/virtualenv"' >> ${HOME}/.bashrc
echo 'export VIRTUALENVWRAPPER_PYTHON="${HOME}/.local/bin/python2.7"' >> ${HOME}/.bashrc
echo 'export VIRTUALENVWRAPPER_VIRTUALENV="${HOME}/.local/bin/virtualenv"' >> ${HOME}/.bashrc
echo 'export VIRTUALENVWRAPPER_VIRTUALENV_ARGS="--python=python2.7"' >> ${HOME}/.bashrc
echo 'source ${HOME}/.local/bin/virtualenvwrapper.sh' >> ${HOME}/.bashrc
# Finish ...
cd ..
echo -e "\n\n ... Done!"
This script will ask for your password in order to install GCC etc. if it needs to, then take a while to build everything - about 25 minutes on my (ancient)
machine and (terrible) internet connection. If you're paying attention, at some
point you'll see the following message scroll past:
Python build finished, but the necessary bits to build these modules were not found:
bsddb185 dl imageop
sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
Those four modules are archaic and/or deprecated, so you don't need to worry
about them. If the message mentions any other modules, that means some
necessary library isn't installed on your system. You can still run Python if that's the case, but won't be able to import those modules. Shout in the comments if you're affected by this, and
I'll update the script accordingly.
Once that's finished successfully, you need to source your .bashrc:
$ source ~/.bashrc
... and you'll then be able to run your newly compiled Python ...
$ python2.7
Python 2.7.3 (default, Nov 17 2012, 02:00:26)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
... create a virtualenv to work in ...
$ mkvirtualenv my_env
$ python
Python 2.7.3 (default, Nov 17 2012, 02:00:26)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
... install libraries into it ...
$ pip install beautifulsoup4
... and so on.
To exit a virtualenv:
$ deactivate
To re-enter it at a later date:
$ workon my_env
For more, check out the documentation for pip and virtualenvwrapper.
I am running Snow Leapord 10.6 and trying to install the following python modules:
numpy
scipy
matplotlib
I am running into problems because OSX contains two version of Python:
/Library/Python/
/System/Library/Frameworks/Python.framework/
It appears that when I execute the following command:
sudo easy_install -U {module}, the modules are being installed to the site-packages directory here:
bash-3.2$ ls -al /Library/Python/2.6/site-packages/
total 688
drwxrwxr-x 12 root admin 408 Aug 24 23:26 .
drwxrwxr-x 3 root admin 102 Feb 11 2010 ..
-rw-rw-r-- 1 root admin 119 Feb 11 2010 README
-rw-r--r-- 1 root admin 267 Aug 24 19:03 easy-install.pth
drwxr-xr-x 5 root admin 170 Aug 24 10:42 nose-0.11.4-py2.6.egg
drwxr-xr-x 38 root admin 1292 Aug 24 15:35 numpy
-rw-r--r-- 1 root admin 1618 Aug 24 15:35 numpy-2.0.0.dev8661-py2.6.egg-info
drwxr-xr-x 16 root admin 544 Aug 24 19:07 numscons
drwxr-xr-x 4 root admin 136 Aug 24 19:03 numscons-0.10.1-py2.6.egg
-rw-r--r-- 1 root admin 265 Aug 24 19:07 numscons-0.12.0dev-py2.6.egg-info
-rw-r--r-- 1 root admin 333959 Aug 23 11:51 setuptools-0.6c11-py2.6.egg
-rw-r--r-- 1 root admin 30 Aug 23 11:51 setuptools.pth
But, when I try to install scipy, I see the following error:
config = setup_module.configuration(*args)
File "scipy/setup.py", line 20, in configuration
config.add_subpackage('special')
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/numpy/distutils/misc_util.py", line 851, in add_subpackage
caller_level = 2)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/numpy/distutils/misc_util.py", line 834, in get_subpackage
caller_level = caller_level + 1)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/numpy/distutils/misc_util.py", line 766, in _get_configuration_from_setup_py
('.py', 'U', 1))
File "scipy/special/setup.py", line 14, in <module>
(numpy.__version__, numpy.__file__))
ValueError: numpy >= 1.4 is required (detected 1.2.1 from /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/numpy/__init__.pyc)
So it appears that it is looking for an older version of numpy in my frameworks directory. I used import to see which version of numpy python was finding:
python -c 'import numpy;print numpy.__version__'
1.2.1
And sure enough, it is looking in the frameworks directory even though I have a new version sitting in:
/Library/Python/2.6/site-packages/
I know import searches your local directory first, and then goes into PYTHONPATH, and then finally looks at sys.path. So I checked these out and I do not have PYTHONPATH set right now, and here is my sys.path:
/Library/Python/2.6/site-packages/setuptools-0.6c11-py2.6.egg
/Library/Python/2.6/site-packages/nose-0.11.4-py2.6.egg
/Library/Python/2.6/site-packages/numscons-0.10.1-py2.6.egg
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload
/Library/Python/2.6/site-packages
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC
/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode
If I change PYTHONPATH to /Library/Python/2.6/site-packages and then check the numpy revision I get the correct version:
bash-3.2$ python -c 'import numpy; print numpy.__version__'
2.0.0.dev8661
But when I run sudo python setup.py build/install scipy cannot find the right numpy, even though PYTHONPATH has been set.
Can anyone please help me out here?
Found this link that looks like it fixes my problem, but I cant seem to get it to work:
http://andreasjacobsen.com/2008/10/10/using-python-setuptools-on-the-mac/
I think the easiest way would be to use MacPorts to install scipy. Here's an intro, though you probably want py26-scipy.
Have you tried installing with pip? Also, try installing scitools, which should pull those you needed.
The issue is that the easy_install you are calling is the one for the Apple install with the frameworks in /System and the python is /usr/bin/python
To see what python gets installed view the easy_install script and see what the #! line says which python to use.
To get the correct easy_install you will need to install distibute or setuptools for the python in /Library (I would guess this is a python.org one with /usr/local/bin/python ). Then use that easy_install
I would note however that I do use #boocs solution of using Macports althogh if just after scipy etc and no other C libraries then other solutions show here will work, also see Enthought
Can you not just move the old numpy out of the way, temporarily ?
cd /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python
sudo mv numpy numpy-1.2.1 # mv back if need be
The solution I came up with is the following.
1) Do not use the version of Python that comes pre-installed with OSX. Apple has apparently made some modifications to this and not everything builds. So, you need to install a development version of Python. Right now - I would suggest installing Python 2.7. Here is a blog post about how to do it:
https://medium.com/cs-math/a3eb146ebfb5
2) Once you have installed Python, you need to install the fortran libraries for the Scipy/Numpy installation. Use homebrew to do that (Do people really still use MacPorts ???)
http://brew.sh/
3) After you have home brew installed, install fortran
brew install gfortran
4) Now you can install scipy/numpy successfully with pip (Warning - it takes a while)
pip install -U numpy
pip install -U scipy
DONE
I had kind of similar problem, just to same some time of the people with the same issue, if you have two pythons in your system (say python2 and python3) and you wish to install say numpy for the new version (python3) go through these steps:
1- download numpy
2-unzip it
3- in terminal go to the unzipped folder
4-python3 setup.py install