I have installed Python 3.8.5 and 3.7 on my computer. By default, it's 3.8.5. So anything that I pip installed is all for 3.8.5. However, I need to install some modules into 3.7 as well.
How can I install modules to that version?
Try this in your terminal or anaconda prompt:
python3.7 -m pip install moduleOfYourChoice
Related
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 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 different python versions installed on my ubuntu machine. The default version is 2.7.
So when I install any new python module, for example using:
#apt-get install python-nfqueue
it will be istalled just for the default version (2.7)
How can I install the new modules for the other versions?
Is there a way to do it using apt-get install?
Thank you!
You should install Python libraries with the Python package installer, pip.
Create a virtualenv with the Python version you want to use, activate it, and do pip install NetfilterQueue. You'll still need to install the system dependencies (eg libnetfilter-queue-dev in this case) with apt-get.
You can install pip to work with different versions of python. Here is a link to the pip read the docs page(http://pip.readthedocs.org/en/latest/installing.html).
to install pip to the default version of python on your machine:
python get-pip.py
to install for non standard versions call python with the version you wish to install for:
python33 get-pip.py
you can then run pip for python version 3.3 by calling
pip33 install pythonmodule
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.