首页 > 解决方案 > 为什么 SQLAlchemy 只安装在我的 Python 2.7 库中?

问题描述

我在 MacOS 上。

我正在尝试为自己编写一个 ETL 模块,但我对我似乎无法让 SQLAlchemy 自行安装在我的 python 3.7 目录中这一事实感到困惑。它在我的 2.7 文件夹中安装得很好,即使我指定:

sudo pip3 install sqlalchemy

这让我发疯!我很想对此事提出任何建议。

以下是我正在做的事情:

User-MacBook-Pro:2.7 User$ pip3 install sqlalchemy --user
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting sqlalchemy
Installing collected packages: sqlalchemy
Successfully installed sqlalchemy-1.3.2
User-MacBook-Pro:2.7 User$ python3
Python 3.7.3 (default, Mar 27 2019, 09:23:15) 
[Clang 10.0.1 (clang-1001.0.46.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlalchemy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'sqlalchemy'
>>> 
User-MacBook-Pro:2.7 User$ pip3 uninstall sqlalchemy
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Uninstalling SQLAlchemy-1.3.2:
  Would remove:
    /Users/User/Library/Python/2.7/lib/python/site-packages/SQLAlchemy-1.3.2.dist-info/*
    /Users/User/Library/Python/2.7/lib/python/site-packages/sqlalchemy/*
Proceed (y/n)? y
  Successfully uninstalled SQLAlchemy-1.3.2
User-MacBook-Pro:2.7 User$ 

标签: pythonmacossqlalchemy

解决方案


尝试

pip3 -V

这将给出这样的东西

pip 19.0.3 from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip (python 2.7)

这样你就可以知道你的 pip 安装在哪里。作为安装给定模块的替代方法,您可以尝试

python3 -m pip install sqlalchemy

推荐阅读