On OSX 10.7.5, I'm trying to use the pip3 command to install packages to python3. When I try, I get this error message:
zak$ pip3
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/setuptools-1.0-py3.3.egg/pkg_resources.py", line 2793, in <module>
File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/setuptools-1.0-py3.3.egg/pkg_resources.py", line 673, in require
File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/setuptools-1.0-py3.3.egg/pkg_resources.py", line 580, in resolve
pkg_resources.VersionConflict: (pip 1.4.1 (/usr/local/lib/python3.3/site-packages), Requirement.parse('pip==1.3.1'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 5, in <module>
from pkg_resources import load_entry_point
File "<frozen importlib._bootstrap>", line 1567, in _find_and_load
File "<frozen importlib._bootstrap>", line 1534, in _find_and_load_unlocked
File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/setuptools-1.0-py3.3.egg/pkg_resources.py", line 2797, in <module>
File "/usr/local/Cellar/python3/3.3.2/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/setuptools-1.0-py3.3.egg/pkg_resources.py", line 576, in resolve
pkg_resources.DistributionNotFound: pip==1.3.1
It looks like setuptools is demanding an old version of pip (I have 1.4.1 installed), but why? How can I fix this?
The problem appears to be that you have two different Python 3.3 installations, and a shared site-packages directory.* And the tool you run as pip3 is from pip 1.3.1, but the modules it uses to do its work come from pip 1.4.1.
The easiest way to solve this, unless you actually need both Python 3.3 installations, is to get rid of both of them completely, then reinstall the one you want.
The following should work (possibly with sudo for some of the commands—or using Finder and letting it tell you whether you need to authenticate).
Note that this will also partially or completely remove any other third-party Python versions (e.g., a python.org 2.7.5), which I don't think is a problem for you, but could be for future readers.
You might want to make a list of all installed packages before uninstalling anything. (I usually do this in the hackiest way possible: fire up ipython, and let it tab-complete an import statement…)
Finally, some of these details will be different for any future readers with similar problems, but the basic ideas should be the same.
brew uninstall python3
rm -rf /Library/Frameworks/Python.framework
rm -rf /usr/local/lib/python*
rm -rf /usr/local/share/python*
Find where in ~/.bash_profile (or ~/.profile or elsewhere) you add the Python paths to your PATH. You may have /usr/local/share/python3 and/or something inside the Python.framework or Cellar/python3. Scrap all that you find.
Fire up a new shell in Terminal.app.
brew doctor, and fix anything that it complains about that seems potentially relevant (the non-Homebrew MacFUSE stuff is fine as-is; the brew prune suggestion is probably worth doing, but doesn't matter here), and run it again to make sure.
brew install python3.
pip3 to reinstall any packages you deleted that you need again.
* Details:
Homebrew Python 3.3 is installed in /usr/local/Cellar/python3/3.3.2/, with various things symlinked into /usr/local/bin and its siblings, and possibly into /Library somewhere.
Another Python 3.3, possibly from the python.org installer, is installed in /Library/Frameworks/Python.framework/Versions/3.3/, with various things possibly symlinked into /usr/local/bin or otherwise added to your PATH.
Both probably include /usr/local/lib/python3.3 in their site-packages search.
After running
pip install --upgrade setuptools
I was able to fix it. But this may not be true for everyone for I am still learning Python.
It seems this was caused by a broken Python installation, I was able to fix it by reinstalling Python with Homebrew.
brew reinstall python3
Related
I'm trying to follow this tutorial on installing Python 3.6.3 and PIP with virtual environments, but when I get to sudo python3.6 get-pip.py I get the error
Traceback (most recent call last):
File "get-pip.py", line 20061, in <module>
main()
File "get-pip.py", line 194, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip
zipimport.ZipImportError: can't decompress data; zlib not available
but I have zlib1g-dev installed and don't know how to fix this problem. I've googled a lot and tried reinstalling, but haven't had any success.
Sorry to start a new question, but I did not have enough Karma to comment on the other one. Any help would be greatly appreciated.
Update: I ended up installing everything from source instead of using any packages and it seems to be working. I was not able to solve the problem, but found an alternative way to get things working.
For pip to work, Python needs to be linked to the zlib library when Python itself is installed. It appears that either zlib was not installed when you installed Python, or at least that the Python installer couldn't locate it. To help it along, you may issue the following before installing Python. In bash syntax,
zlib_lib="/usr/lib32"
zlib_inc="/usr/include"
export CPPFLAGS="-I${zlib_inc} ${CPPFLAGS}"
export LD_LIBRARY_PATH="${zlib_lib}:${LD_LIBRARY_PATH}"
export LDFLAGS="-L${zlib_lib} -Wl,-rpath=${zlib_lib} ${LDFLAGS}"
Here I've assumed that zlib is installed under /usr/lib32 and /usr/include/. To check this, look for the libz.so.1 file in the "lib" directory and the zlib.h file in the "inc" directory. If you find them somewhere else, simply change zlib_lib and zlib_inc accordingly.
IF you have different versions of Python installed it is likely the install is on another version. for example. I have pyperclip in 3.6.3 32bit version, but I an not access it in 3.6.3 64bit or 3.7.2dev.
I am trying to install a software using pip install and my python and pip versions are 3.5. but when I run sudo pip install -e . I get the following error.
Traceback (most recent call last):
File "/usr/local/bin/pip3.5", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.14-py2.7.egg/pkg_resources.py", line 2675, in <module>
parse_requirements(__requires__), Environment()
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.14-py2.7.egg/pkg_resources.py", line 552, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==8.1.0
Why Do I get an error with python 2.7 and please some one could sortout my issue.
Your pip version and python versions are separate. It looks like your package requires exactly pip 8.1.0. You have to either upgrade/downgrade to that version first, or modify the software to work with whichever pip you have available.
Also, it may be easier to install the software in a virtual environment rather than system/global one. Changing the system version of pip may break either current apps, or the future pip package updates.
I have attempted to install PIP using the following commands:
sudo yum install python-setuptools
sudo easy_install pip
sudo pip install supervisor
As it installed, a number of syntax errors were raised from the second and third lines. The errors are fairly similar to that below, so for brevity I'll omit here, but let me know if having those will help. There are a lot.
When I run any pip command, I get SyntaxErrors:
# pip
Traceback (most recent call last):
File "/usr/bin/pip", line 7, in ?
sys.exit(
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 236, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 2097, in load_entry_point
return ep.load()
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 1830, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.4/site-packages/pip-8.1.1-py2.4.egg/pip/__init__.py", line 208
except PipError as exc:
^
SyntaxError: invalid syntax
I am running CentOS release 5.11 (Final) and Python 2.4.3 (#1, Jan 9 2013, 06:47:03). Note, these are managed by WHM.
I have re-installed PIP using python get-pip.py --ignore-installed, but get the same result.
Is this a Python version conflict? Is my version of Python too old and the syntax in the PIP scripts different? What should I do?
except PipError as exc: isn't a valid Python 2.4 syntax (it should be except PipError, exc).
I don't think pip is meant to work with Python 2.4. Try this question for installing PIP 1.1, which is compatible with that version of Python:
Installing Pip on 2.4
As the above answer describes, you've run into version conflicts between pip and python. You're using an old version of CentOS with an old version of python 2, which makes things worse.
Updating the system environment with 'sudo pip' has a very high risk of creating version problems with system utilities. You can, for instance, break yum, and be forced to update your system with rpm commands. You need to install a recent version of python (preferably python 3) as an alternate install in /usr/local/bin or in a user directory.
Then I highly recommend using a virtual environment (https://virtualenv.pypa.io/en/latest/, or a built-in capability in python 3.5). That lets you set up your own python executable, libraries, and installed packages any way you like, without risk of affecting your entire system. It's a minor setup pain, but it makes most of the problems just vanish.
I was trying to follow the instruction from this link :http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/
However, it seems my python can not find the Numpy, Scipy and everything I install using pip.
Right now, when I type which python, it shows /usr/local/bin/python.
However, when I type
pip install numpy
it shows
Requirement already satisfied (use --upgrade to upgrade): numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python.
Thus it seems they are in different directory, and probably I installed numpy previously, which makes pip keep telling me they are installed. I wonder is there any way around that ?
update, I have tried to import it.
import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
I have also tried to uninstall the numpy and install it again. However, when I uninstall it. It still gives me error.
applematoMacBook-Air:~ apple$ pip uninstall numpy
DEPRECATION: Uninstalling a distutils installed project (numpy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling numpy-1.8.0rc1:
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info
Proceed (y/n)? y
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/basecommand.py", line 246, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/commands/uninstall.py", line 70, in run
requirement_set.uninstall(auto_confirm=options.yes)
File "/usr/local/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_set.py", line 274, in uninstall
req.uninstall(auto_confirm=auto_confirm)
File "/usr/local/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_install.py", line 730, in uninstall
paths_to_remove.remove(auto_confirm)
File "/usr/local/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/req/req_uninstall.py", line 126, in remove
renames(path, new_path)
File "/usr/local/lib/python2.7/site-packages/pip-6.1.1-py2.7.egg/pip/utils/__init__.py", line 292, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
os.unlink(src)
OSError: [Errno 13] Permission denied: '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'
Seems like the version of pip you are using is using the default mac system-wide python interpreter /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python instead of the one installed in /usr/local/bin.
I've pretty much experienced the same issues until I started using homebrew. I'd recommend to have a look at this page on brew and python. You'd might need to remove pip and reinstall it from brew. Btw, using brew, there's no need for sudo.
try: pip uninstall numpy
and then: pip install numpy
...and try it with sudo:
sudo pip install numpy
first, you should use pip list to check out have you installed numpy .
if you already installed, check out your program IDE whether the pycharm, and check the pycharm interpreter does the local interpreter or virtual interpreter. if the interpreter is virtual, you should change to local. if it works, you can create the new project with select the local interpreter.
more detail: https://www.jianshu.com/p/9c3507cca2b9
in my problem, i can't update scikit-learn with pip install -U scikit-learn, and occur the problem
Cannot uninstall 'scikit-learn'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
it occured in your error too. so, i find your problem.
and i try the commod pip install -U --ignore-installed scikit-learn, and it solve my problem.
I have a Mac running Python 2.6. When I try to use easy_install I get this message:
/usr/bin/easy_install-2.6:7: UserWarning: Module pkg_resources was already imported from /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.pyc, but /Library/Python/2.6/site-packages is being added to sys.path
from pkg_resources import load_entry_point
/usr/bin/easy_install-2.6:7: UserWarning: Module site was already imported from /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site.pyc, but /Library/Python/2.6/site-packages is being added to sys.path
from pkg_resources import load_entry_point
Traceback (most recent call last):
File "/usr/bin/easy_install-2.6", line 10, in <module>
load_entry_point('setuptools==0.6c9', 'console_scripts', 'easy_install')()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 271, in load_entry_point
return False
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 2173, in load_entry_point
deps = []
ImportError: Entry point ('console_scripts', 'easy_install') not found
I am very confused by this and I want to know how I can fix this. Previously I didn't get this message, then after installing pip and uninstalling it, easy_install no longer works. I was wondering how I could fix this, or restore the default Python or easy_install setting on Mac.
Check your /usr/bin and /usr/local/bin for easy_install installations and remove any old script:
sudo rm -f /usr/bin/easy_install*
sudo rm -f /usr/local/bin/easy_install*
Download and run distribute:
curl -O https://svn.apache.org/repos/asf/oodt/tools/oodtsite.publisher/trunk/distribute_setup.py
sudo python distribute_setup.py
sudo rm distribute_setup.py
Try again, and enjoy. E.g.:
sudo easy_install pip
I suspect the easiest way you can get easy_install working again is to install distribute, which is an improved version of distutils that bundles it's own version of easy_install. Installation is simple:
curl -O http://python-distribute.org/distribute_setup.py
/usr/bin/python2.6 distribute_setup.py
I had the same problem just after installing the new Operating System (Lion OSX).
After install python and execute it
sudo easy_install ipython
ipython
I got the following error:
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 8, in <module>
load_entry_point('ipython==0.10.2', 'console_scripts', 'ipython')()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 318, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2220, in load_entry_point
raise ImportError("Entry point %r not found" % ((group,name),))
ImportError: Entry point ('console_scripts', 'ipython') not found
Then I realize it was a permission problem. If I execute the ipython script as sudo it worked.
sudo ipython
So I changed the ownership from root to my user () of the folder /Library/Python/2.7/site-packages/
sudo chown -R <your_user>:wheel /Library/Python/2.7/site-packages/
Use change ownership only if you don't have several accounts that uses python.
I hope it work for you.
Best
Your setuptools installation is broken. The easy_install-2.6 script in your /usr/bin directory, is only a wrapper that loads the actual easy_install module in your Python installation, and the latter is missing. Presumably uninstalling pip either broke the pointer to it (usually in the form of a .pth file in your site-packages directory) or removed the whole package but didn't remove the /usr/bin/easy_install-2.6 wrapper script.
Your best bet is to re-install setuptools from scratch again, by following the instructions on the setuptools PyPI page.
I had the same problem, I suspect caused by my installation of Homebrew which apparently installs its own version of easy_install blindly and screws up whatever you're currently running (enough times for homebrew to recognize it as a problem). I found my solution here Upgraded Python on Snowleopard Using Homebrew now pip and easy_install don't work
While I'm actually on Lion, it still fixed my problem. You just download ez_setup.py from http://pypi.python.org/pypi/ez_setup - run ez_setup.py through terminal and you're off to the races.
I had a similar error message after following similar steps. I suspect it's because I tried to install the distribute module, and it tried to install a new version of setuptools which
didn't quite work because it failed to correctly override the Mac OS X supplied setuptools. But that's only a suspicion.
I fixed my problem by doing the following. I found that the directory /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python
had 4 files with .OLD in the name. When I did a compare with similarly named files without the .OLD from when things worked (via Time Machine) I found that they were the same except for the name. So I did the following renames:
setuptools.OLD.1305936263.57 ->
setuptools
setuptools-0.6c9-py2.6.egg-info.OLD.1305936263.57 -> setuptools-0.6c9-py2.6.egg-info pkg_resources.py.OLD.1305936263.57
-> pkg_resources site.py.OLD.1305936263.59 -> site.py
I had to use the command line and sudo mv because the files are owned by root. For example: sudo mv setuptools.OLD.1305936263.57 setuptools. You'll have to enter your password.
The other thing I did was clean the /Library/Python/2.6/site-packages directory. I used Time Machine to set it back to its pre-messed up state. If you don't have Time Machine, then you should be able to recover if you delete any files or folders beginning with distribute, easy-install, pip, pkg_resources, setuptools and site.
If that doesn't do the trick, uninstall any modules you can from that directory. For example use pip uninstall if you installed modules with pip. The reason to do this is that installation can copy files into usr/local/bin and other places that pip will remove for you.
Next it's time to remove any remaining modules. Rename the folder (in case there's something you want later) and make a new empty one.
Reinstall the modules you want and with a little luck you're back in business...
Martijn Pieter's answer is correct.
Go to http://pypi.python.org/pypi/setuptools#downloads
Download setuptools-0.6c11-py2.7.egg
From your downloads directory run: sudo ./setuptools-0.6c11-py2.7.egg
Done :-)