Issue
I have just installed a python virtual environment in my Debian 4.19.132-1 (Python3.8) via
python3 -m venv myapp
and noticed the following; inside my lib folder (myapp/lib) there are two subfolders, python3.8 and python3.7.
If I use commands like
pip install
the module will be installed in myapp/lib/python3.8/site-packages. But if I run
python
the version that'll be running is the 3.7.3. In this case, I have to use
python3.8
to have access to the right version.
My question here is, if I used my 3.8 installation to create a virtual environment, what does this 3.7 version is doing there? And there is some way to remove it to no let it cause malfunctions in my programs?
Thanks in advance!
EDIT:
Result of dpkg -l python3
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-============-============-=========================================================================
ii python3 3.7.3-1 amd64 interactive high-level object-oriented language (default python3 version)
Result of type -all python3
python3 is /usr/bin/python3
Relevant results of ls -l
drwxr-xr-x 18 gabriel_fernandes google-sudoers 4096 Oct 7 14:14 Python-3.8.2
-rw-r--r-- 1 root root 17869888 Oct 7 13:06 Python-3.8.2.tar.xz
Solution
Sounds like somebody installed Python 3.8 alongside Python 3.7 but forgot to rename pip
so the new one takes precedence over the system-installed 3.7 one.
In some more detail, Debian out of the box ships Python 3.7 in /usr/bin/python3
but for Python development you also want to have the latest and greatest version, which somebody seems to have installed from source, probably somewhere like /usr/local/bin/python3.8
.
If that pip
version is /usr/local/bin/pip
(rather than, say, /usr/local/bin/pip3.8
) it will shadow the system pip
in /usr/bin/pip
which is for 3.7 (also depending on your PATH
, but conventionally /usr/local/bin
takes precedence over /usr/bin
).
We can't tell for sure why this was done this way, but it seems the naming of pip
(or rather, failure to rename the new version so it doesn't shadow) was a mistake. In sane organizations, you would have a supervisor or mentor who could tell you what you are supposed to do with this computer, and perhaps point to some documentation if this is something the organization does systematically.
Answered By - tripleee