I am using a raspberry pi 2 board with Raspian. In order to be consistent with my mac I created a separate version of Python v2.7.10. I installed a number of packages that where recommended and I was able to compile it. I placed it in /usr/local/opt/Python2.7.10. I then updated my path environment so that this directory comes first. The original Python 2.7.3 is located at /usr/bin
Now I need to get pip installed. I downloaded get-pip.py and executed it. pip was installed in /usr/local/bin, which is not where either versions of Python exists. This doesn't look right to me. I am not sure if this pip is for the original Python or for the newer version of Python that I created. I just don't want to mix the two. Is this the correct location or do I need to get it somewhere in /usr/local/opt/? I am not sure how to get pip to install in /usr/local/opt/Python2.7.10/bin.
pip: dealing with multiple Python versions?
To use pip on a specific Python, you need to make sure you have downloaded pip and installed pip for that python version:
curl -O https://bootstrap.pypa.io/get-pip.py
/path/to/python27 get-pip.py
Then use specific pip version to install packages:
pip2.7 install somePackage
Related
So im pretty new to python and i need pip for something i wanna do, but everytime i install python the Scripts folder where pip should be always installs empty. I make sure that install pip is checked when downloading python. How do I get it to install pip with python?
If you installed Python, it came bundled with pip.
The default packages:
C:\Users\<Your username>\AppData\Local\Programs\Python\Python310\Lib\site-packages
A better practice is to install a venv for every project you are working on. Every venv will have its own set of dependencies(i.e. packages), and it will be easier to manage them.
You can find installed packages in your venv:
YOUR_PROJECT_PATH\venv\Lib\site-packages
EDIT
From official docs:
Pip not installed¶ It is possible that pip does not get installed by default. One potential fix is:
python -m ensurepip --default-pip
There are also additional resources
for Installing pip
I think I broke my pip after desperately trying to uninstall Python3.7. (I am on a Mac)
I removed the python folder from the application, removed /Library/Frameworks/Python.framework and removed the folders from /usr/local/bin according to https://osxuninstaller.com/uninstall-guides/properly-uninstall-python-mac/. I then installed python3.6.
src$ pip3.6 --version pip 9.0.1 from
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
(python 3.6)
but pip itself does no longer work.
src$ which pip
/usr/local/bin/pip
src$ pip --version
-bash: /Library/Frameworks/Python.framework/Versions/3.7/bin/pip: No such file or directory $
It still references the python 3.7 folder. How can I unlink that reference? THe same is btw. true for the package virtualenv that I installed. I can install it with pip3.6 but calling virtualenv still references to the framework folder of 3.7
You need to install pip in that environment. i.e 3.7.
Reason is when you deleted the default install you deleted the dependencies/ libraries that came with it.
Easiest way is to install python afresh via homebrew if you have it.
brew install python
Alternatively you can follow the instructions here to download a file to install pip securely. Homebrew can become messy when managing python environments. I'd recommend looking at something like anaconda if you are going to using different python versions with their own dependencies etc.
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py
Other options for fresh install are described in answer here. Hope that helps.
How do I install pip on macOS or OS X?
I'm having problems while installing a new package in Python. I was looking for the termcolor package. I installed it using the apt:
sudo apt-get install python-termcolor
But when I try to use it in Python 3.6 it keep telling me that's not installed. I checked whether it was and I got:
cris#Manaos:~$ dpkg -L python-termcolor
/.
/usr
/usr/share
/usr/share/pyshared
/usr/share/pyshared/termcolor-1.1.0.egg-info
/usr/share/pyshared/termcolor.py
/usr/share/doc
/usr/share/doc/python-termcolor
/usr/share/doc/python-termcolor/README.rst
/usr/share/doc/python-termcolor/copyright
/usr/share/doc/python-termcolor/changelog.Debian.gz
/usr/share/doc/python-termcolor/CHANGES.rst
/usr/lib
/usr/lib/python2.7
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/termcolor-1.1.0.egg-info
/usr/lib/python2.7/dist-packages/termcolor.py
So I understand that the package was correctly installed, but in the v2.7. How do I get it installed in the v3.6?
EDIT: I've read that if a use the pip installer, I could assign in which version of Python I'd like it installed, like using pip3 to install the package in 3.XX. But I tried it, it says that it was correctly installed and when I open Python 3.6 and try to use it, still got the ModuleNotFoundError.
EDIT2: After checking one more time, I discovered that with pip3 I installed the termcolor package in Python 3.5.3, but how can I get it installed in Python 3.6.1?
You need to specify you want the python 3 version.
sudo apt-get install python3-termcolor
I am trying to install jupyter on mac,
I understand that the mac comes with python version installed
But i also installed brew and installed python through brew.
When i check python location i get:
which python
/usr/bin/python
When i check pip location i get:
which pip
/usr/local/bin/pip
When i try to install jupyter:
pip install install
after a long installation it tried to remove python package that it want's to upgrade
And fails:
On trying to uninstall dateutil.
I think its the mac packages.
I tried with sudo, no change.
As far as i can understand it because the files are immutable.
Tried to remove the immutable with:
chflags uchg.
No change.
I also tried to work with virtual env, using:
sudo pip install virtualenvwrapper.
But that pip tries to uninstall another python folder.
Any suggestions?
Thanks
UPDATE:
The brew seems to create links from python2. to python2
And the same for python3.
I tried to create the link myself, It worked and i was manage to install the package i wanted. But its not a good solution,
The all point of brew is to manage this things for me, next time i will upgrade python it will break.
Any suggestions why? could it be because the brew installed two python version on my laptop?
RESOLVED:
Found the answer, thanks to #tdube question i went and looked what brew guys did to python and found this thread from Jan 17.
I turns out that they changed the behavior or installing python.
No you don't have simply python any more.
You have python2 and python3.
No more simply pip, now you have pip2 and pip3.
That is a major change from the default behavior of how people use python
Especially that mac comes with a default python
so now you have
python that is /usr/bin/python
python2 that is /usr/local/bin/python2
python3 that is /usr/local/bin/python3
this is the fix, the brew guys suggest ( you can see it when running brew info python ):
==> Caveats
This formula installs a python2 executable to /usr/local/bin.
If you wish to have this formula's python executable in your PATH then add
the following to ~/.zshrc:
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
Pip and setuptools have been installed. To update them
pip2 install --upgrade pip setuptools
You can install Python packages with
pip2 install <package>
They will install into the site-package directory
/usr/local/lib/python2.7/site-packages
See: http://docs.brew.sh/Homebrew-and-Python.html
You can read about it in this thread:
The Python that comes "pre-installed" on Mac is located in /usr/bin/python. I think you need to change the order of the entries in your PATH environment variable as noted here (python homebrew by default). Which file your PATH is set in depends on which shell you are using.
So I heard about the proper way to install packages into python by creating a new virtual environment for every project. Being on a mac (10.8) I have installed python3 using Homebrew, then I installed pip and virtualenv on this copy.
Now here comes the problem:
I create a new virtualenv, and activate it using:
virtualenv testing
source testing/bin/activate
When I type
which python
/Users/mik/Desktop/testing/bin/python
But typing
which pip
/usr/local/bin/pip
(learned of this when trying to install a package in the virtual environment, and it installed in the system wide installation in /usr/local/)
Inside the folder testing there is no file referring to pip
Extra Question: How does pip know which python to install the files to, for example pip list (which I believe refers to python 2.7) outputs the names of packages installed on python 3.3
I'll start with the last question as it explains what is happening.
The commands pip and easy_install are python scripts which are made executable on the filesystem. The python they use is the python that the first line tells to run the script. e.g. in /usr/bin/easy_install it is #!/usr/bin/python This will be Apple's python. So easy_install will install the 2.7 version of pip and virtualenv and will ignore your python3.3 setup.
The way to instal into python 3 is to install the 3.3 version of pip and virtualenv, the easiest way would be to install the Homebrew package for them. I think it is easier and less confusing to use just one package manager (Homebrew here) and not two (i.e. Homebrew and python).
You can also install easy_install directly. The way to do this is install the distribute package using python3.3 explicitly.
Python 3.4 will make this much easier as pip will always be available