I have two versions of python installed. 2.7 and 3.7.4. I want to install Pygame to 3.7 but am failing.
I've tried multiple tutorials and methods but no luck. Python 2.7 has all the files but 3.7 has only exes but still works perfectly fine.
If you are using pip, you could always try specifying the exact Python versions to install for:
$ python2.7 -m pip install pygame
$ python3.7 -m pip install pypgame
Related
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 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
My mac has python3 and python2 installed by default.
Before now, only python3 and pip3 commands were working on the macOS terminal. But when I upgraded my pip pip3 install --upgrade pip, my pip command works as well, and when I type python --version it shows 2.7.16. Although I still have python3 installed, I don't like having python2. Can I uninstall python2 or is it just not possible?
Keep in mind that the python --version command showed an error before I upgraded pip
If Python 2 was installed onto your Mac by default, do NOT try to remove it as it is not possible, and could break your entire operating system.
As #GavinWong said, do not try to remove Python 2 from your Mac. Some of the scripts used by the operating system are written in Python 2 and hence Python 2 must be available for Mac to fubtion properly.
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 am using RedHat Linux.
Python 2.6 is already installed in usr/src/bin. When I install Python 2.7, it gets installed in usr/local/src/bin.
Further, I need to install sklearn. When I try installing sklearn using pip, it refers to Python2.6 and not Python2.7.
You can run python -m pip to see if pip is using the right version of python
I think you can probably specify the location with usr/local/src/bin pip install If you're sure that's where python 2.7 is installed. If pip is not using python 2.7 you should reinstall pip in the correct version.
There is another question which could help solve yours:
Pip Install not installing into correct directory?