testuser at ~]-pip3 install Request
Requirement already satisfied: Request in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (2019.3.22)
Requirement already satisfied: post in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from Request) (2019.3.22)
Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from Request) (40.6.2)
Requirement already satisfied: get in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from Request) (2019.3.22)
Requirement already satisfied: query-string in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from get->Request) (2019.3.22)
Requirement already satisfied: public in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from query-string->get->Request) (2019.3.22)
You are using pip version 18.1, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
testuser at ~]-pip install Request
Requirement already satisfied: Request in /anaconda3/lib/python3.7/site-packages (2019.3.22)
Requirement already satisfied: post in /anaconda3/lib/python3.7/site-packages (from Request) (2019.3.22)
Requirement already satisfied: setuptools in /anaconda3/lib/python3.7/site-packages (from Request) (40.8.0)
Requirement already satisfied: get in /anaconda3/lib/python3.7/site-packages (from Request) (2019.3.22)
Requirement already satisfied: query-string in /anaconda3/lib/python3.7/site-packages (from get->Request) (2019.3.22)
Requirement already satisfied: public in /anaconda3/lib/python3.7/site-packages (from query-string->get->Request) (2019.3.22)
testuser at ~]-which python
/anaconda3/bin/python
testuser at ~python3 -c "import Request" && echo $?
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'Request'
>>> print(sys.path)
['', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/testuser/Library/Python/3.7/lib/python/site-packages', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages']
>>>
答案1
看来您想python
从非标准位置使用。
设置PYTHONPATH
和PYTHONHOME
变量让它知道:
export PYTHONPATH=/anaconda3/bin/python
export PYTHONHOME=/anaconda3/
答案2
修复了设置 PATH 的问题,我的 sys.executable 指向“/Library/Frameworks/Python.framework/Versions/3.7/bin”并将其重置为“/anaconda3/bin/python3”