'Python packages are located in differente location
- I am using Ubuntu 20.04 which comes python 3.8.
- I installed python3.9 and made it as default python
update-alternatives - under /usr/bin/ I have python2.7/ python3/ python3.8/ and python3.9/
==> Now the problem that I am facing is when I installed sqlalchemy using pip install sqlalchemy its version was 1.3.12, which has a compatibility problem with pandas because it requires version '1.4.0'.
>>>pip install --upgrade sqlalchemy
>>> Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: sqlalchemy in /usr/lib/python3/dist-packages (1.3.12)
Collecting sqlalchemy
Downloading SQLAlchemy-1.4.31-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.6/1.6 MB 8.3 MB/s eta 0:00:00
Collecting greenlet!=0.4.17
Downloading greenlet-1.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (156 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 156.6/156.6 KB 9.6 MB/s eta 0:00:00
Installing collected packages: greenlet, sqlalchemy
Successfully installed greenlet-1.1.2 sqlalchemy-1.4.31
I wrote the same command again it gave me this :
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: sqlalchemy in ./.local/lib/python3.8/site-packages (1.4.31)
Requirement already satisfied: greenlet!=0.4.17 in ./.local/lib/python3.8/site-packages (from sqlalchemy) (1.1.2)
I also did this to check:
>>>pip show sqlalchemy | grep Location
>>>Location: /home/Moe/.local/lib/python3.8/site-packages
but when I import sqlalchemy in a script it still uses the old version it seems that the new version is installed in a different location
>>> print(sqlalchemy.__file__)
>>>/usr/lib/python3/dist-packages/sqlalchemy/__init__.py
Can Someone please explain this to me, and if possible explain the entire package management problem here
Solution 1:[1]
You are calling pip that is associated with your python 3.8, you can see that in the whl file that is downloaded:
Downloading SQLAlchemy-1.4.31-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Note the cp38
And in the output of running the install again:
Requirement already satisfied: sqlalchemy in ./.local/lib/python3.8/site-packages (1.4.31)
Note the python3.8.
Since you have mentioned that you downloaded python 3.9, you are probably running your scripts using that version of python. You will need to use the pip that is associated with that python. If you are running your script with
python <scriptfile>
Then you should pip install with
python -m pip install ...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | FlyingTeller |
