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.
Related
I'm trying to make a pip install of the fastf1 library. I noticed that I was using py 3.7 and that lib requires 3.8 or superior. I updated my interpreter (to python 3.10) but, the pip install keeps returning "ERROR: Could not find a version that satisfies the requirement fastf1". My python --version returns 3.10, but my pip version, although updated, still calling the anaconda's pip
How do I change the main pip to be used in this project?
Terminal result:
PS C:\Users...\Github\speedmetrica\DataAnalysis> python --version
Python 3.10.0
PS C:\Users...\Github\speedmetrica\DataAnalysis> pip --version
pip 21.3.1 from c:\users\jgbal\anaconda3\lib\site-packages\pip (python 3.7)
If python --version is running the desired version of Python, instead of running:
pip install packagename
run:
python -mpip install packagename
That runs the pip module installed for that version of Python as the entry point using the same Python executable you've been running, so it will install for that version of Python as well.
If you're on Windows, and installed as admin to install the Python launcher for Windows, you can be avoid relying on the PATH having a specific version appear first by running:
py -3 -mpip install packagename
which will run the latest installed version of Python 3. Changing to:
py -3.10 -mpip install packagename
will force it to run the latest installed copy of Python 3.10 specifically.
Currently, my python version is 2.7.16 and after I run pip install virtualenv then I enter python -m virtualenv venv then I get this error msg
"/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named virtualenv"
But when I run pip freeze | grep virutalenv, I get virtualenv==20.4.2, which is the latest version. My guess is if I downgrade virtualenv to 20.0.1 then system will recognize virtualenv, since I'm using old python version. I looked around for documents, but there were no info on how to do this.
Does anybody know how to downgrade virtualenv version from mac terminal?
try
pip uninstall virtualenv
pip install virtualenv==20.0.1
My guess is it has to do with your python path, not at all with the version
try to nano ~./bash_profile
and
export PYTHONPATH=$PYTHONPATH:path/to/your/venv
then
source ~./bash_profile
The above is adding the path to the module to your python path so that python sees it
I am working on a GPU instance on AWS. There are some already provided Conda environments. I am using tensorflow2_latest_p37 environment.
This environment has 2 python 3 versions .i.e python 3.6 and python 3.7.
All the preinstalled packages are available in python 3.7
But whenever I am trying to do pip install dlib it would install it for python 3.6.
How can I install this for python 3.7?
Run the command:
which python.
Probably it will show you python3.6,
it means that your default python version is 3.6.
You need to search your pip3 path.
path/to/pip3 install dlib.
If you know how to use the Python 3.7 environment, you can simply use python -m pip install ... or more exactly:
command_for_python3.7 -m pip install package_name
If unsure, you should search for commands starting with python in /bin, /usr/bin and /usr/local/bin. You could also have Python installations under /opt.
On Windows, the magic word is py:
py 3.7 -m pip install package_name
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 have 2 Python versions
Python 3.4.3
Python 2.7.10
Env variable works with Python 3.4(in my system), so when I pip install*package_name it will only install the package into Python 3.4
I have a system variable for Python 2.7 -- %python27% -- also.
My question is; how can I pip install a package/module into Python 2.7 without changing the Env. Variable.
Note: %python27% pip install *package_name doesn't work.
Thank you.
You should have multiple executables of pip.
Use pip2 and pip3 interchangeably.
Anyway, you should consider using virtualenv package, initialize it like virtualenv -p /usr/bin/python2.7 env_name or virtualenv-3.4 -p /usr/bin/python3.4 env_name then each time you use your code, type source env_name/bin/activate and "python" should be aliased to virtualised version.
You can use pip for python2 and pip3 for python3.
Also you can try using virtualenv or pyenv
I had the same problem, but it was installing to Python 2.7 rather than Python 3.4. Using $ pip3 install *package_name solved the issue.