【问题标题】:Cannot pip install SolrClient (python2.6 vs 3.4 issues?)无法 pip 安装 SolrClient(python2.6 与 3.4 的问题?)
【发布时间】:2016-05-13 04:37:14
【问题描述】:

我正在尝试 pip install SolrClient,我相信我的 python 版本有些困难。

这是错误信息。

[root@centos64 ~]# pip install SolrClient
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Collecting SolrClient
Using cached SolrClient-0.1.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/pip-build-UeQsqQ/SolrClient/setup.py", line 4, in <module>
    import SolrClient
  File "SolrClient/__init__.py", line 1, in <module>
    from .solrclient import SolrClient
  File "SolrClient/solrclient.py", line 10, in <module>
    from .collections import Collections
  File "SolrClient/collections.py", line 7, in <module>
    from collections import defaultdict
ImportError: cannot import name defaultdict

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-UeQsqQ/SolrClient/

所以,当我去检查我的python版本时,它是2.6

[root@centos64 ~]# python -V
Python 2.6.6

我的机器上有 python 3.4,尽管我需要这样称呼它

[root@centos64 ~]# python3.4 -V
Python 3.4.3

所以,有几个问题。

我是否正确地假设我的错误是由于我尝试使用 python2.6 进行 pip 安装?

如果是这样,我该怎么做

a) 告诉 pip 使用 python3.4 版本? (不确定这是否是正确的思考方式)

b) 调整我的系统以使用 python3.4

否则,我不确定如何在此处继续。想法?

【问题讨论】:

  • Am I correct in my assumption that my error is due to the fact that I am attempting to pip install using python2.6? - 是的。处理这种情况的干净方法是创建一个 virtualenv 并作为默认 python 放入您的 PATH
  • 使用我假设的 pew?
  • 我刚刚点击了你提供的 SolrClient 的链接,我看到上面写得很清楚,它需要 py3.3 及更高版本意味着它不适用于 python2.x

标签: solr centos pip python-3.4 python-2.6


【解决方案1】:

我确实需要使用python3.4

按照建议,我为该任务使用了一个虚拟环境。

pip install pew

pew new -p `which python3.4` 3.4

pew workon 3.4

pip install SolrClient

【讨论】:

    【解决方案2】:
    sudo apt install virtualenv
    virtualenv -p python3 <envname>
    cd <envname>
    source bin/activate
    pip install SolrClient
    

    【讨论】:

    • 您能否为您的答案添加解释?
    • 不支持python 2.x版本,只能安装python 3.3+。
    • 如果你不想要 virtualenv 并且想要全局安装。然后使用这个'python3 -m pip install SolrClint'。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-25
    • 2017-12-16
    • 1970-01-01
    • 2012-02-12
    相关资源
    最近更新 更多