Python 包位于不同的位置
- 我使用的是 Ubuntu 20.04,它带有 python 3.8。
- 我安装了 python3.9 并将其设置为
- /usr/bin/ 下的默认 python
update-alternatives
我有 python2.7/ python3/ python3.8/ 和 python3.9/
==>现在我面临的问题是,当我使用 pip install sqlalchemy 安装 sqlalchemy 时,它的版本是 1.3.12,它与 pandas 存在兼容性问题,因为它需要版本“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
我再次编写了相同的命令,它给了我这个:
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)
我也这样做是为了检查:
>>>pip show sqlalchemy | grep Location
>>>位置:/home/Moe/.local/lib/python3.8/site-packages
但是当我在脚本中导入 sqlalchemy 时,它仍然使用旧版 看来新版本安装在不同的位置
>>> print(sqlalchemy.__file__)
>>>/usr/lib/python3/dist-packages/sqlalchemy/__init__.py
有人可以向我解释一下吗,如果可能的话在这里解释整个包管理问题
- 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在调用与 python 3.8 关联的
pip
,您可以在下载的 whl 文件中看到:注意 cp38
并在再次运行安装的输出中:
注意python3.8。
由于您提到您下载了 python 3.9,因此您可能正在使用该版本的 python 运行脚本。您将需要使用与该 python 关联的 pip。如果您正在运行脚本,
那么您应该使用
pip install
You are calling
pip
that is associated with your python 3.8, you can see that in the whl file that is downloaded:Note the cp38
And in the output of running the install again:
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
Then you should
pip install
with