我似乎无法正确安装requests包。不管我用什么来实际运行我的程序,我都会得到同样的错误:
Traceback (most recent call last): File "/Users/garce/Desktop/songlyrics/getlyrics.py", line 2, in <module> import requests ModuleNotFoundError: No module named 'requests'
然而,我已经使用pip来安装请求。当我在终端窗口中运行pip show requests
时,它会出现以下内容:
Name: requests Version: 2.24.0 Summary: Python HTTP for Humans. Home-page: https://requests.readthedocs.io Author: Kenneth Reitz Author-email: me@kennethreitz.org License: Apache 2.0 Location: /Users/garce/opt/anaconda3/lib/python3.8/site-packages Requires: urllib3, idna, certifi, chardet Required-by: Sphinx, jupyterlab-server, conda, conda-build, anaconda-project, anaconda-client
我认为这是某种路径问题,但我不知道这里出了什么问题。知道吗?
您是全局安装该包,还是在pipenv环境中安装?如果在全球范围内,您尝试过pipenv吗?它不仅被认为是最佳实践,而且我发现使用pipenv或Anaconda环境通常可以解决我遇到的路径问题。