I am working on ubuntu, I have python 3.8 as standard installation.
However as my project have dependency on python 3.7 I have installed 3.7 and removed 3.8
now when I am trying to install pip it is installing python3.8 again and getting installed with 3.8.
I am using apt-get -y install pip to install pip.
I want to install pip on top of my python3.7 installation so that pip uses python3.7
my project have dependency on python 3.7
This is where virtual environments really useful. The idea is that you create an environment in which the required version of python and packages can live without altering the installation of python you might want to keep installed for other projects.
There are a few options, but Anaconda / miniconda are a popular way of using virtual environments and fairly easy to use. First you'll need to install miniconda:
https://docs.conda.io/projects/conda/en/latest/user-guide/install/linux.html
After that from a terminal you need to create your new environment
conda create -n "py3p7" python=3.7
Then activate it:
conda activate py3p7
Then check that you've got pip installed and it's installed under the right python version:
pip --version
Which for me returns:
pip 22.2.2 from /home/MY_NAME/miniconda3/envs/py3p7/lib/python3.7/site-packages/pip (python 3.7)
Related
Want to use python3.9 with actual pip and venv. And remove python3.8.
I've installed python3.9 like that. Then pip. And python3.9-venv using apt.
Problem is pip and venv use distutils. Whish downloads via python3-distutils (python3.9-distutils is virtual package which refers to python3-distutils) and drags python3.8 with it.
I tried to remove python3.8 with all that methods one by one. But each time distutils removes along with python3.8. I read that dialogue. And I'm not quite sure but it seems there is no distutils outside of python3.8 package.
So am I nailed forever with python3.8 or there is solution to remove it safely? Or somehow extract distutils and tie it with python3.9?
Do not remove the system Python
The Ubuntu 20.04 system needs Python 3.8 for its own functionality. The system Python, in this case Python 3.8, should not be removed, because that can make the system instable.
Python 3.8 does not need to be removed to use Python 3.9.
More info here: https://unix.stackexchange.com/questions/652299/changing-pythons-default-version-breaks-ubuntu-20-04
No need for python3.9-distutils
python3-distutils works for both Python 3.8 and Python 3.9, no need for python3.9-distutils.
Source: https://github.com/deadsnakes/issues/issues/150#issuecomment-761180428
Create a venv virtual environment with Python 3.9
yourname#machine:~$ python3.9 -m venv /home/yourname/.venvs/my-venv-name
Activate the virtual environment:
yourname#machine:~$ source /home/yourname/.venvs/my-venv-name/bin/activate
Check the python version, it should be 3.9:
(my-venv-name) yourname#machine:~$ python -V
Python 3.9.9
Check the pip version within the venv, it is probably different than the system pip version:
(my-venv-name) yourname#machine:~$ pip3 --version
pip 21.2.4 from /home/yourname/.venvs/my-venv-name/lib/python3.9/site-packages/pip (python 3.9)
Deactivate the virtual environment:
(my-venv-name) yourname#machine:~$ deactivate
Check the system pip version, outside any venv:
yourname#machine:~$ pip3 --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
I have python 2.7 installed on my machine globally and the pip version is pip 20.3.4. I want to install Django version 1.11.22. When I am trying to do so with pip install Django==1.11.22, I am getting the error as mentioned in the picture. This is not just while installing Django, I am getting the same error while installing anything like pip install openpyxl.
The latest version Python 2.7.18 should work fine. Install it with pip enabled or install pip after using python -m ensurepip. Upgrade pip:
pip install --upgrade "pip<21.0" "setuptools<45"
Install virtualenv:
pip install --upgrade "virtualenv<20"
Create a virtual environment (very much recommended) somewhere and activate it:
virtualenv django-venv
django-venv\Scripts\activate.
Install Django (can be done without a virtual environment):
pip install --upgrade "Django==1.11.22".
Remember to activate the virtual environment (if you use it) every time you open a new terminal.
As the error says and #Willem Van Onsem said, python 2.7 is no longer support, you can't install it nowadays
I have just installed Anaconda with Python3.7 on my Ubuntu 18.04. Ubuntu 18.04 comes with Python3.6 by default (but not pip).
After installing Anaconda and reading its documentation, I can see that Anaconda comes with both conda and pip. This is the case, as I can see:
$ which pip
# Output: /home/user-name/anaconda3/bin/pip
$ pip --version
# Output:
pip 10.0.1 from /home/user-name/anaconda3/lib/python3.7/site-packages/pip (python 3.7)
However, I am confused when reading the instructions from this link:
https://conda.io/docs/user-guide/tasks/manage-pkgs.html#installing-non-conda-packages
On one hand it says: " Both pip and conda are included in Anaconda and Miniconda, so you do not need to install them separately." => That's the pip I can see in my commands above.
But on the other hand it says: " It is possible to have pip installed outside a conda environment or inside a conda environment. To gain the benefits of conda integration, be sure to install pip inside the currently active conda environment, and then install packages with that instance of pip. The command conda list shows packages installed this way, with a label showing that they were installed with pip.
So I'm confused:
I clearly got a version of pip when installing Anaconda and I can see in /home/user-name/anaconda3/bin
But if I want to use pip to install a package, I need to install pip in my environment using $ conda install pip and then $ pip install package (all of this in my normal Ubuntu terminal).
I don't understand how this makes sense..
Many thanks!
I have 2 anaconda in my system: one with python 2.7 & and another with python 3.5.
My command prompt is showing python version as 2.7.
I need to install one package for Python 3.5 using pip only,not conda install. I installed it using pip. It's showing installed successfully, but I'm not able to import it in Anaconda with Python 3.5.
My python 2.7 path is given in path environmental variable. Can you suggest me how to install it using pip install for python 3.5?
I don't have python 3 installed in my system. I think I have anaconda 3.5 environment in my system. Please refer the screen shot. Also I can't able to install python 3.5 in my system
To install a package in specific version, try this:
A specific version of python:
$ python-3.5 -m pip install <pkg-name>
Assuming you mean that you have two conda environments, go to a Anaconda command prompt and activate the Python 3.5 environment. Then, if pip is not installed, do:
conda install pip
Then, you should be able to run
pip install <package>
to install in to Python 3.5 provided that you are in the Python 3.5 environment.
If you don't have a Python 3.5 environment yet, simply do
conda create --name py35 python=3.5
followed by
activate py35 (Windows)
source activate py35 (Linux or macOS)
You can use:
pip install --install-option="--prefix=$PATH_PREFIX" <package_name>
or
pip install -t <direct directory> <package_name>
How do you install Python 3.6.x in a virtualenv using pip in Windows 10?
pip install python, pip install python3, pip install python3.6 don't work.
Pip and virtualenv are two separate tools. Pip is a package manager, you will use it to install packages into your virtual environment once it has been set up. Pip does not actually manage the virtual environment. Virtualenv is the tool that handles creating virtual environments.
First, you should check if you have virtualenv installed with virtualenv --version. If you do not have it, you will get an error that virtualenv is not found. You can use pip to install virtualenv with pip install virtualenv.
Once you have virtualenv, you can create a python 3.6 environment with virtualenv -p python3.6 /path/to/myvirtualenv. You will need an installation of python 3.6 for this command to work, so download and install python 3.6 first if you do not have it.
I believe that on windows if you don't have python 3.6 in your PATH variable, you may need to point directly to the python 3.6 installation instead with virtualenv -p /path/to/mypython3.6 /path/to/myvirtualenv.
See Virtualenv User Guide