Pip using python osx system

I installed python26 using macports, so the correct python in my system is /opt/local/bin/python

However when i do

 sudo pip install <packagename> 

It gives me

 sudo pip install <somepackage> Exception: Traceback (most recent call last): File "/Library/Python/2.6/site-packages/pip-1.0.1-py2.6.egg/pip/basecommand.py", line 126, in main self.run(options, args) File "/Library/Python/2.6/site-packages/pip-1.0.1-py2.6.egg/pip/commands/install.py", line 215, in run import setuptools ImportError: No module named setuptools Storing complete log in /Users/navin/.pip/pip.log 

So, I suspect that he is using system python. I installed the distribution (which contains setuptools) through their instructions on the site. I also installed pip through the installer. I somehow managed to build setuptools for system python, I think, so I am having this problem now :(

What should I do to work with pip again?

+7
source share
5 answers

Remove pip from / usr / local / bin with sudo rm /usr/local/bin/pip .

If you installed pip with macports, which pip should show /opt/local/bin/pip . If not, install the program again following the instructions here . While which python shows the installation of /opt/local , it should work. If this is not the case, you need to edit the env PATH variable.

+12
source

To summarize above, install pip using Macports using

 sudo port install py27-pip 

leads to the installation of a package named py27-pip.

However, neither /opt/local/bin/pip and port select pip or port select py27-pip both refused (unlike port select python ). Changing the settings in the bin another distribution is usually not recommended.

Note that /usr/bin python links point to Apple's pre-installed python, /usr/local/bin points to those installed by MacPython from python.org , whereas /opt/local/bin where Macports sets its links. Actual library settings can be found with ls -ls applied to different python files in each bin ).

To ensure that Macports files are called, export the path for Macports last in .bash_profile . For example, if you installed Macports and then installed the binary distribution from python.org, you will end your path with it later ~/.bash_profile , so it will be the first in the path variable, and Macpython will obscure Macports.

After ensuring that the paths are installed correctly, the system still does not find the pip command in the Macports bin because it is installed as pip-2.7 and pip is automatically created.

As a result, the system continues to search for the path and, if, for example, Macpython is added to the path later and installs pip, after which pip appears.

This can be avoided with the command suggested above:

 sudo ln -s /opt/local/bin/pip-2.7 /opt/local/bin/pip 
+14
source

Here is my setup to get pip to work with macports and set py26-pip as default peak

 sudo port install py26-pip && sudo port select --set pip py26-pip 

after installation is complete, run to view help information for pip

 pip --help 

after you may need to update your path to include the bin files installed in pip, edit the .bash_profile file to include something like

 export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin:$PATH 
+3
source

You must have python and pip installed in / opt / local / bin / before those installed in / usr / local / bin /.

In addition, you should check which python running and set the pip to / opt / local / bin / pip.

+1
source

I found that I need ln -s /opt/local/bin/pip-2.7 /opt/local/bin/pip . For some reason, macports did not build this link even when you try to activate this version of python or pip.

0
source

All Articles