Pip Using System Python Osx
Solution 1:
UPDATE: I strongly recommend installing CPython by building from source (example), and then creating virtual environments to work in.
Summarizing the above, installing pip using Macports:
sudo port install py39-pip
results in an installation of a MacPorts port named py39-pip.
However, no /opt/local/bin/pip is installed and port select pip or port select py27-pip both fail (in contrast to port select python). Changing things in the bin directory of another distribution is not recommended.
Note that Python files in:
/usr/binare of the preinstalled Python of macOS/usr/local/binare installed by MacPython, available from python.org/opt/local/binare installed by MacPorts.
The actual executable files can be found by ls -ls applied to the various Python-related symbolic links found in each of the above bin directories).
To ensure that the Python installed by MacPorts is called first, place /opt/local/bin within the runtime environment's PATH earlier than /usr/bin and /usr/local/bin. This can be done in the file ~/.bash_profile or the file ~/.bashrc (which one depends on your system and configuration). For example, writing
export PATH=/opt/local/bin:$PATHlast in ~/.bashrc will have this effect (assuming that the intended shell will source the file ~/.bashrc).
After the paths have been appropriately defined, the system still fails to find a pip command in the Macports bin directory, because it is installed as /opt/local/bin/pip3.9. The file /opt/local/bin/pip is not automatically created.
As a result, the system continues searching the PATH, and if e.g. MacPython is added to the path some place later and has pip installed, then that pip will show up.
This can be avoided by the command proposed above:
sudo ln -s /opt/local/bin/pip3.9 /opt/local/bin/pip
Solution 2:
Remove pip from /usr/local/bin with sudo rm /usr/local/bin/pip.
If you have installed pip with macports, which pip should then show /opt/local/bin/pip. If not, install pip again by following the instructions here. As long as which python shows the /opt/local installation, it should work. If it doesn't, you will need to edit your PATH env variable.
Solution 3:
Here is my setup to get pip working with macports and set py26-pip as the default pip
sudo port install py26-pip && sudo port select --set pip py26-pip
after install finishes run to see the help information for pip
pip --helpafter you may need to update your path to include the bin files installed by pip edit .bash_profile to include something like
export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin:$PATHSolution 4:
You should have the python and pip installed in /opt/local/bin/ prior to those installed in /usr/local/bin/.
Also, you should check to execute which python and whether the pip was installed in /opt/local/bin/pip.
Solution 5:
I found I needed to ln -s /opt/local/bin/pip-2.7 /opt/local/bin/pip. For some reason macports didn't built that link, even when you try activating that version of python or pip.
Post a Comment for "Pip Using System Python Osx"