I'm trying to install Pandas through pip install on python 3.8 but the terminal tries to use the pip from python 3.9 on my computer, though I had thought I deleted everything from the python 3.9 folder. For reference, 3.8 and 3.9 look like this:
Under Python3.9/Scripts, there is a pip installer for python 3.9. If I just delete the lib and scripts folder from python 3.9, will the pip installer automatically default to 3.8?
Thanks
The short approach, remove python3.9 from your Windows Env Variables.
The best approach is using VirtualENV with the custom Python version.
1.- install VirtualEnv
2.- Create an ENV in your terminal with your specific Python version.
virtualenv venv -p=/c/Programs/Python/Python38/python.exe
3.- Activate your VirtualEnv with
source venv activate
Now you have your installation isolated.
I fixed my issue, I just had to delete the entire python3.9 folder containing lib and script.
I had python 3.8 installed and then I installed python 2.7. I am trying to run a python program with py -2 program.py in vs code using with python 2.7 as selected environment and I am getting an error, ImportError: No module named googlemaps even though I have already installed.
If I run the program using Python3 then it would run fine. Also when I open vs code using python 2.7 as selected runtime environment then I would get a warning Linter Pylint is not installed. If I click on install then I would get another warning There's no Pip installer available in the selected environment.
Also even though I have changed the python path from 3.7 to 2.7, default python version will still show up as 3.7 when I runPython in command line.
Things that I have tried to install the googlemaps module for python 2 after googling for solutions,
pip2 install googlemaps--upgrade
py -2 -m pip install googlemaps
If you have your python2 binary located, you can just call it directly:
/usr/bin/python2 -m pip install googlemaps
And if you're not sure where your python binary is, you can use
import sys
print(sys.executable)
to locate it.
And if you don't have pip, you should install it by downloading this file:
https://bootstrap.pypa.io/get-pip.py
then running:
/usr/bin/python2 get-pip.py
It is recommended to install Python 3.8 using Pyenv and also when you are using different versions of python, it is very useful
curl https://pyenv.run | bash
pyenv install 3.8.1
pyenv virtualenv 3.8.1 venv
pyenv local venv
with pyenv local you set your version for use.
If after this you run
pyenv version
It will output to 3.8.1
With regards to pip installation, run
whereis python
and if it outputs to
usr/bin/python2
then you can use pip for installing python2 packages and pip3 for packages compatible to python3.
I have
python --version
Python 3.6.9 :: Anaconda, Inc.
but
pip3 --version
pip 19.2.2 from /home/ss/.local/lib/python3.5/site-packages/pip (python 3.5)
pip --version
pip 19.2.2 from /home/ss/.local/lib/python3.5/site-packages/pip (python 3.5)
I installed pip for anaconda as
conda install -c anaconda pip
But it did not change the pip path, it is still 3.5 sys path.
How do I use pip installed in anaconda python dir for python 3.6.9?
Use python -m pip <operation>
The reason you want to use python -m <module> is that pip might not necessarily refer to the python installation you are referring to. Even if you have run activate /some/env, that still doesn't guarantee that the pip binary will be the one used.
For instance, the $PATH environment variable might have the python paths appended rather than prepended, so pip might live in /usr/local/bin which will be searched first, giving the wrong pip.
However, you know which python you want to use, and by using the -m flag, you explicitly tie that module to the python version specified by python
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 am on shared hosting and I need to install pip with the correct python version, 2.7. To install pip, I did:
$ easy_install pip
However, after it was installed I get the following:
[dave#web1 lib]$ pip --version
pip 1.0.2 from /home/premiere/dave/financials/lib/pip-1.0.2-py2.7.egg (python 2.4)
How would I re-install pip to work on the python2.7 version, which is also installed on the machine?
[premiered#web1 ~]$ python --version
Python 2.6.6
Which is strange, since it is installing to python2.4.
You may want to create a virtualenv using -p /path/to/python-2.7.binary param, and then activate it. Then all stuff you installed using pip would be correctly into your virtualenv.
If multiple versions of python are installed on the system, then you should invoke the version you want when installing. i.e.
$ python27 easy_install pip
This creates a pip file in your path that contains the specified version of python in the hashBang line.