I have installed python 3.9 in Ubuntu, because it comes with python 3.8 which is an older version.
I changed the command for terminal alias python 3 = python 3.9, but when I installed pip, it installed for python 3.8 and after that when I am using pip install to install python packages, it installs for python 3.8. How can I fix it?
try with pip3 install
This kind of issue even happened to my case when I was working with the python modules recently on my project. Try this out it worked for me.
Due to variations in the installation process of python, pip often requires different ways to access for different people. A few examples that may help you include pip3 install, py pip install py -3 pip install or python3 pip install. Usually one of these works for me.
I'm a new Python user. I'm having issues installing new modules for python 2.7. When I try installing a new module from PyCharm, I get the following error
Error: Python packaging tool 'pip' not found
Moreover, I'm a bit confuse about which Python version I'm actually using...
This is what I get when I type the following commands in the terminal.
$ which python
/usr/bin/python
$ echo $PYTHONPATH
PYTHONPATH:/usr/local/lib/python3/dist-packages/
$ python -V
Python 2.7.6
Everything seems a bit messed up to me...all the procedures I follow to install pip result in failure. The command
$ python get-pip.py
returns
You are using pip version 7.1.0, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command
However, when I run that command, it tells me that there is no module named pip.
Please, how can I fix it? I need to work with Python 2.7 but I'm completely unable to install packages. Thanks.
EDIT I am using Ubuntu 14.04 LTS
You may be trying to install pip wrong. Depending on your version of linux there are several install methods that can be found here
for your version judging by your use of get.
try this one:
sudo apt-get install python-pip
Ubuntu 14.14 server itself has installed Python 3.4 in default, however, I need to use Python 3.5 for certain packages. So I install it by myself.
The problem is that every time I try to install packages by running "pip3 install xxx". It always installs under Python 3.4 rather than 3.5.
Please show me some lights on how to use Python 3.5 properly on Ubuntu. Many thanks for any good suggestions!
To install it to the right version of python, type:
sudo python3 -m pip install [package]
Now this is assuming the name of Python 3.5 is python3.
If this is not the case,
Create an alias of Python 3.5 to some name
Replace python3 in the snippent above with that name.
Execute the command.
I am using Windows 10. Currently, I have Python 2.7 installed. I would like to install Python 3.5 as well. However, if I have both 2.7 and 3.5 installed, when I run pip, how do I get the direct the package to be installed to the desired Python version?
You will have to use the absolute path of pip.
E.g: if I installed python 3 to C:\python35, I would use:
C:\> python35\Scripts\pip.exe install packagename
Or if you're on linux, use pip3 install packagename
If you don't specify a full path, it will use whichever pip is in your path.
Because usually i change my intepreter to run something(i got 2 diff projects with both 2 and 3), i use these solution:
Add path to the environment as usual (of course)
Rename ur python.exe , in my case i want to run python 3 using command python3 on my cmd. So i renamed my python.exe in python3.x directory with python3. Itll works with python 2 ofc.
Then to use pip in both python, i use this command.
python3 -m pip install 'somepackage'
and to run pip on python2
python -m pip install 'somepackage'
This is may not the best solution out there, but i like this one
** WINDOWS **
ref : https://datascience.com.co/how-to-install-python-2-7-and-3-6-in-windows-10-add-python-path-281e7eae62a
In my case, I have Python 2.7 and Python 3.4, with the Python Launcher for Windows.
This is the output when running this commands:
PS C:\> pip -V
pip 9.0.1 from c:\python27\lib\site-packages (python 2.7)
PS C:\> pip3 -V
pip 9.0.1 from C:\Python34\lib\site-packages (python 3.4)
I'll note that in my Python27\Scripts\ directory, I have pip.exe, pip2.exe and pip2.7.exe.
And in my Python34\Scripts\ directory, I have pip.exe, pip3.exe and pip3.4.exe.
So all of these .exe files help you when you have different versions of Python installed at the same time.
Of course, for this to work, you have to have the respective Scriptsdirectries in your Path system enviroment variable.
The answer from Farhan.K will work. However, I think a more convenient way would be to rename python35\Scripts\pip.exe to python35\Scripts\pip3.exe assuming python 3 is installed in C:\python35.
After renaming, you can use pip3 when installing packages to python v3 and pip when installing packages to python v2. Without the renaming, your computer will use whichever pip is in your path.
I would advise against ever calling any pip script directly (nor pip3, pip2.7.exe, anything like that).
Instead, a surefire way is to always prefer the explicit variant of calling pip's executable module for a specific Python interpreter:
path/to/pythonX.Y -m pip somecommand
path/to/venv/bin/python -m pip somecommand
C:\path\to\venv\Scripts\python.exe -m pip somecommand
There are many advantages to this, for example:
It is explicit for which Python interpreter the projects will be pip-installed (Python 2 or 3, inside the virtual environment or not, etc.)
For a virtual environment, one can pip-install (or do other things) without activating it: path/to/venv/bin/python -m pip install SomeProject
Under Windows this is the only way to safely upgrade pip itself path\to\venv\Scripts\python.exe -m pip install --upgrade pip
But yes, if all is perfectly setup, then python3 -m pip install SomeProject and pip3 install SomeProject should do the exact same thing, but there are way too many cases where there is an issue with the setup and things don't work as expected and users get confused (as shown by the many questions about this topic on this platform).
References
Brett Cannon's article "Why you should use python -m pip"
pip's documentation section on "Upgrading pip"
venv's documentation section on "Creating virtual environments": "You don’t specifically need to activate an environment [...]"
I ran across an issue with running pip with absolute path. This might be related to WinPython's installation routine and the order of installing Python 3.6 first, 2.7 second, or Python 3.6 being in the path.
No matter which pip was called, it was activating the 3.6 one:
λ C:\prog\WinPython-64bit-2.7.13.1Zero\python-2.7.13.amd64\Scripts\pip2.exe --version
pip 9.0.1 from C:\prog\WinPython-64bit-3.6.1.0Zero\python-3.6.1.amd64\lib\site-packages (python 3.6)
What finally did the trick was calling pip as a module of the respective python binary:
λ C:\prog\WinPython-64bit-2.7.13.1Zero\python-2.7.13.amd64\python.exe -m pip --version
pip 9.0.1 from C:\prog\WinPython-64bit-2.7.13.1Zero\python-2.7.13.amd64\lib\site-packages (python 2.7)
Hope that might help someone with similar issues.
I tried many things , then finally
pip3 install --upgrade pip worked for me as i was facing this issue since i had both python3 and python2.7 installed on my system.
mind the pip3 in the beginning and pip in the end.
And yes you do have to run in admin mode the command prompt and make sure if the path is set properly.
1-open command prompt and change direction using the command cd C:\Python35\Scripts
2- write the command pip3 install --upgrade pip
3- close the command prompt and reopen it again to return to the default direction and use the command pip3.exe install package_name to install any package you want
I have two versions of python installed on my machine (Ubuntu 14.xx LTE) as well as two versions of pip (one for python 2 and one for python 3). When I run pip --version on the command line I get the following output: pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7). I looked into this directory and it has many other things in it. However I couldn't find pip.py in it. How do I run pip for python 3? Any help is appreciated.
To use another version of pip for python on ubuntu, you can use the python major version after pip. For Example:
pip --version
will return the default version of pip
pip2 --version
will use the Python 2 version of pip, and
pip3 --version
will use Python 3.
Hope this helped!
rename your python.exe for python 3 to python3. Don't forget to put it inside your PATH environment. Just use python for python 2, python3 for python 3.
Their pip are separated, pip for python 2. pip3 for python 3.