我正在尝试安装一个库并在 PyCharm 上运行它。尝试通过 PyCharm 安装它,但我无法安装,发生了一些错误:
Collecting Google-Search-API
Using cached Google-Search-API-1.1.13.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/5t/y8w_0_2j52l866cgl2p2q0nm0000gn/T/pycharm-packaging0.tmp/Google-Search-API/setup.py", line 15, in <module>
with open("test_requirements.txt") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'test_requirements.txt'
连同错误消息一起,有一个建议:
“尝试从系统终端运行此命令。确保使用为位于 '/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5' 的 Python 解释器安装的正确版本的 'pip' 。”
凉爽的。所以我去了终端,做了一个export PATH=/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5:$PATH
以确保 pip 将 lib 发送到正确的位置。
尝试后pip install Google-Search-API
,一切似乎都很好:
MacBook-Air-2:~ santanna_santanna$ pip install Google-Search-API
Requirement already satisfied: Google-Search-API in /anaconda/lib/python2.7/site-packages
没有错误,一切都很酷。
所以我回到 PyCharm 并按照 [Google-Search-API GitHub][1] 中的建议输入:
import google
并得到:
ImportError: No module named 'google'
我一直在绞尽脑汁在 PyCharm 上安装和使用它。
注意:在完成export PATH=...
终端后我做了 awhich python
并且终端给我的答案是//anaconda/bin/python
编辑
试过sudo /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 -m pip install Google-Search-API
了,我得到的错误与 PyCharm 上的错误非常相似:
The directory '/Users/santanna_santanna/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/santanna_santanna/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting Google-Search-API
Downloading Google-Search-API-1.1.13.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-build-j2qk3_00/Google-Search-API/setup.py", line 15, in <module>
with open("test_requirements.txt") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'test_requirements.txt'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-j2qk3_00/Google-Search-API/
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.