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)
Related
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)
I have successfully installed Python 3.10. I want to install packages. Pandas, BeautifulSoup4, and requests.
I tried to import NumPy but IDE says it doesn't have the NumPy module.
I searched for it in directories and it turned out NumPy is in the 3.8 version.
I used the command on the terminal:
sudo python3 -m pip install Pandas
Which installed it successfully.
But the package files are installed in Python 3.8.
Now I have the following Directories:
/Library/Python 3.8
/Library/Frameworks/Python.framework/Versions 3.10
/Applications/Python 3.10
/usr/local/bin 3.10
In /Library/Python there is only 2.7 and 3.8 versions
In following directories version is 3.10:
/Library/Frameworks/Python.framework/Versions 3.10
/Applications/Python 3.10
/usr/local/bin 3.10
/usr/local/bin
/Library/Frameworks/Python.framework/Versions
/Applications/Python
What will happen if i remove 3.8 or can i update it to 3.10?
Is better to use a virtual environment and install in it python 3.10, removing Python 3.8 can may some problems, so avoid removing it, and if you are open to using different tools, I advise you to use Jupyter Notebook.
Don't follow this (go to EDIT instead):
I found my answer here:
https://stackoverflow.com/a/25123329/13377578
Just had to specify the version of Python I want to install the package in.
sudo python3.10 -m pip install Pandas
Now it works. Thanks.
EDIT:
Thanks for the comments below. I am new to Python and didn't know what environments were.
I followed this simple guide.
I made an environment for my project (my system-level python is now safe from messing up) and now everything works.
Create Environment:
cd python-projects
Python3.10 - m venv Venv_Name
source pit-ds/bin/activate
Installing Packages:
pip list
pip install Pandas
pip install BeautifulSoup4
pip install Requests
Run IDLE within Virtual Environment:
python -m idlelib.idle
Deactivating Environment:
deactivate
I'm trying to install multiple python versions in linux, but asdf or pyenv get stuck with an error:
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
apt install libssl or apt install libssl1.0 didn't solved...
I already have version 2.7 and 3.8 by default.
Then I've stalled version 3.4 by downloading its source and building manually. If i try to create a virtual environment like python3.4 -m venv myenv, i can activate python --version shows the correct one:
$ python --version
Python 3.4.0
but pip still referenced to python 3.8:
(myenv)$ pip --version
pip 21.0.1 from ~/.local/lib/python3.8/site-packages/pip (python 3.8)
/usr/local/lib/python3.4/site-packages/ only has README file, and i can't figure out how to properly set this
I have a python app build on python 3.4
Due to an OS update I have to update this app to python 3.5.
First step I did was this to create new python version path in env
python3 -m venv --upgrade ENV_DIR
But how can I reinstall the needed packages from requirements.txt into this new 3.5 path?
When I do
pip install -r requirements.txt
it says all packages are already installed.
What am I doing wrong? Can someone help me?
Thank you
You can also use pyenv for multiple python versions.
Install pyenv
check available python versions using pyenv.
pyenv install --list | grep " 3.[45]"
Install the version you want. Here you will need 3.4
pyenv install 3.4(Any version you want)
Find available versions
pyenv versions
Go to local folders where your project is there. Set python 3.4 version
pyeve local 3.4
Check python version. It would be 3.4
python --version
Create virtual Environment
python -m venv venv
Install all packages using
pip install -r requirements.txt
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