Python

时间:2018-01-23 20:40:55

标签: python pycharm anaconda google-search-api conflicting-libraries

我试图安装一个库并在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'

与错误消息一起出现了消息:

  

&#34;尝试从系统终端运行此命令。请确保你   使用正确版本的&#39; pip&#39;为你的Python解释器安装   位于   &#39; /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5'&#34;

冷却。所以我去了终端,做了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=...上做了which 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.

2 个答案:

答案 0 :(得分:1)

根据其PyPI页面https://pypi.python.org/pypi/Google-Search-API,此包处于alpha状态,仅支持Python 2。这可能是它安装错误的原因。

我建议使用替代解决方案来查询Google搜索API,或者如果绝对必须使用此软件包,请切换到Python 2。

答案 1 :(得分:1)

也许你改变了另一种可能性,但对于那些想要在python3中开发的人来说

安装包

facecolors

然后插入以下命令(确保您已安装git)

plt.scatter(real(zeros), imag(zeros), s=50, marker='o')

命令:

unidecode (py -3.5 -m pip install unidecode) selenium (py -3.5 -m pip install selenium) bs4 (py -3.5 -m pip install bs4)

对于python版本3.5,如果你处理多个python版本它是一个舒适的方法所以它将从python 3.5目录调用pip

它是从github repo下载的,在这种情况下,我对丢失的.txt文件没有任何问题,对我来说非常适合