I have various versions of Python on my Ubuntu OS.
When I want to install futures, it writes the following message:
$ sudo pip2 install futures
Requirement already satisfied: futures in /usr/local/lib/python3.8/dist-packages (3.1.1)
When uninstall it and install it again, it does not help.
How would you install futures for Python2?
All the pips that I have (pip, pip2, pip2.7, pip3, pip3.6, pip3.7, pip3.8) point here:
pip 20.2.3 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)
Can I change it?
Running pip install something may do what you expect if everything is configured well, but in general it often happens that you do not really know in which python that is going to install something.
To be certain in which python you are installing, it is best to run python -m pip instead of just pip. That way you can choose exactly which python installation should be updated, by simply using the same Python you would use to run later when you use the installed library e.g.:
python -m pip install something
or
python3 -m pip install something
or
/usr/bin/python2.7 -m pip install something
or
"C:\Program Files\Python3.6\python.exe" -m pip install something
or ...
Related
I was trying to install preview-generator and so I typed pip install preview-generator and I got this: ERROR: Package 'preview-generator' requires a different Python: 2.7.16 not in '>= 3.4' so I tried pip install -U pip and it said that Requirement already up-to-date: pip in ./.local/lib/python2.7/site-packages (20.3.4) so how would I update it?
Edit: I tried pip3 install preview-generator and it worked
My suggestion is: don't mess your system's python installation. There might be other modules that depend on that being what it is. Use pyenv to manage python versions.
Check https://github.com/pyenv/pyenv
Check this post for a detailed explanation: https://realpython.com/intro-to-pyenv/
I am using a MacOS 10.15 and Python version 3.7.7
I wanted to upgrade pip so I ran pip install --upgrade pip, but it turns out my pip was gone (it shows ImportError: No module named pip when I want to use pip install ...)
I tried several methods like python3 -m ensurepip, but it returns
Looking in links: /var/folders/sc/f0txnv0j71l2mvss7psclh_h0000gn/T/tmpchwk90o3
Requirement already satisfied: setuptools in ./anaconda3/lib/python3.7/site-packages (49.6.0.post20200814)
Requirement already satisfied: pip in ./anaconda3/lib/python3.7/site-packages (20.2.2)
and pip install still does not work and returns the same error message.
I also tried easy_install pip and other methods but pip still does not work.
Can anyone help me with this?
Update:
Using the method from #cshelly, it works on my computer!
Try the following:
python3 -m pip --upgrade pip
The -m flag will run a library module as a script.
The pip used by python3 is called pip3. Since you're using python3, you want to do pip3 install --upgrade pip.
Since it says no module named pip, thus pip is not installed in your system
So you may try
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
to download pip directly then you can use execute it using -
python3 get-pip.py
For details you may refer - https://www.geeksforgeeks.org/how-to-install-pip-in-macos/
PS: You may need to use sudo to make use of administrative privileges.
I want to install pillow, but when I run pip install pillow in the cmd I get the following message:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting pillow
Downloading https://files.pythonhosted.org/packages/5e/b6/8960697526a79bd1cb4520293078be3a10d725f23f20abbee298ebdeaabd/Pillow-6.2.2-cp27-cp27m-win_amd64.whl (1.9MB)
|ERROR: Could not install packages due to an EnvironmentError: [Errno 42] Illegal byte sequence
WARNING: You are using pip version 19.2.3, however version 20.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
Python 3.8.2 is already installed on my computer and I added it to PATH.
I also ran python -m pip install --upgrade pip and nothing has changed.
What is the problem? Do I need to update the Python version?
Installation using third party PPA repository
Step 1: First install the Ubuntu software properties package if it’s not already installed on your system.
$ sudo apt update
$ sudo apt install software-properties-common
Step 2: After that run the commands to add the PPA.
$ sudo add-apt-repository ppa:deadsnakes/ppa
Step 3: Finally, run below to install Python 3.8
$ sudo apt update
$ sudo apt install python3.8
You can check as below:
$ python3 --version
Python 3.8.1
OK done.
Don't use the pip, pip3, etc. scripts ever. Instead always prefer the more explicit and surefire way of calling pip's executable module for a specific instance of the Python interpreter, for example:
path/to/pythonX.Y -m pip install Pillow
References:
https://snarky.ca/why-you-should-use-python-m-pip/
https://snarky.ca/a-quick-and-dirty-guide-on-how-to-install-packages-for-python/
Check if Python3 is correctly installed by, for example, running python3 -V in the command-line (this will show you the installed version)
This should show something like Python 3.8 ...
If you get an error here, like it is an unknown command, something probably went wrong during the installation...
Run pip3 install pillow to install pillow (Python 3)
Kindly download it at Python official website.
There is an option to update your version during the installation which is very useful.
Edit:
So now which pip, which python and which python3 have started working correctly somehow. I was also able to install libraries using pip. The only remaining problem is that of the apt_pkg. Running apt-get install python-apt gives:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-apt is already the newest version (1.6.3ubuntu1).
Running any python application still gives error: ImportError: No module named apt_pkg
Running echo $PATH returns:
/home/hamza/bin:/home/hamza/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Running find /usr -name python -o -name python3 returns:
/usr/local/lib/python3.5/dist-packages/notebook/static/components/codemirror/mode/python
/usr/local/lib/python2.7/dist-packages/notebook/static/components/codemirror/mode/python
/usr/lib/python3
/usr/lib/gimp/2.0/python
/usr/lib/libreoffice/share/Scripts/python
/usr/lib/virtualbox/sdk/bindings/xpcom/python
/usr/lib/wx/python
/usr/bin/python
/usr/bin/python3
/usr/share/code/resources/app/extensions/python
/usr/share/bash-completion/helpers/python
/usr/share/bash-completion/completions/python
/usr/share/bash-completion/completions/python3
/usr/share/python
/usr/share/javascript/codemirror/mode/python
/usr/share/python3
/usr/share/lintian/overrides/python
/usr/share/lintian/overrides/python3
/usr/share/gcc-8/python
/usr/share/gdb/python
/usr/share/librevenge/python
/usr/share/doc/python
/usr/share/doc/python3
/usr/share/doc/python-statsmodels/examples/python
/usr/share/playonlinux/python
Original:
Python on my system is a wreck. I have got multiple versions installed. None work properly. Apparently some applications using python are not working either (eg: Unity Tweaks). My python libraries will not install because pip doesn't work, although it says it is already installed
I was trying to install some libraries for python on my system using pip. Turned out pip was not working. I tried to reinstall pip only to learn that pip was already installed. I went through a process of understanding the difference between python and python3. I have tried enough things and have basically lost track of the things I have done to get the libraries installed. Long story short, pip does not work no matter what, my libraries will not install and consequently my code doesn't run.
Here is some of the things I have already done:
which pip
This return no output
apt-get install python-pip
Says I have pip already installed
apt-get install python-apt
To resolve ImportError: No module named apt_pkg. It says:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-apt is already the newest version (1.6.3ubuntu1).
But the error persists
And countless other stuff I do not remember.
What I want now is simple. I wish to somehow get out of this hassle by resetting all of my python settings and installation to default, and then install the pandas and numpy libraries for my system. Any and all help would be appreciated.
Result for python -m pip -V:
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
Result for python3 -m pip -V:
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.5)
One of the following commands worked for me:
pip3 install -U pip
python -m pip install -U pip
python3 -m pip install -U pip
Make sure the version of your python3 is 3.6, which is the default version of ubuntu18, then upgrade pip.
export py3_path=`which python3`
rm $py3_path
ln -s `which python3.6` $py3_path
python3 -m pip install -U pip
Or use pyenv to manage multi versions https://github.com/pyenv/pyenv
I have two versions of python installed on my computer (3.6 and 3.7). Just upgraded pip to the latest version (19.0.1) using the command python -m pip install --upgrade pip however i think it only upgraded the pip for python version 3.6. When attempting to install a package specifically for python version 3.7 with the following command pip3.7 install scipy i got the message saying You are using pip version 18.1, however version 19.0.1 is available. Clearly only the pip for version 3.6 was upgraded. I cannot figure out a command to upgrade 3.7 pip as well. I tried the following:
python -m pip3.7 install --upgrade pip
This did not work (Trying to use the logic of how packages are handled for different versions of python). Could not find a question that addressed this specific issue. Any help would be greatly appreciated.
Use the python 3.7 interpreter to run the command:
python3.7 -m pip install --upgrade pip
Or use the pip3.7 binary directly:
pip3.7 install --upgrade pip
export LD_LIBRARY_PATH=/usr/lib64
activate pip3
I ran into the same problem. If you have Microsoft Visual also installed the best command to use is
py -m pip install --upgrade pip --user
I used that command, and it worked like a charm.