【问题标题】:cloudant module will not install with pipcloudant 模块不会与 pip 一起安装
【发布时间】:2020-06-08 22:25:07
【问题描述】:

尝试使用 IBM 网页上的说明在 raspberry pi ver 1 rev b 上安装 cloudant 模块。

第一:git clone https://github.com/IBM-Cloud/get-started-python

然后:cd get-started-python

终于:pip install -r requirements.txt

我想在 python 2.7 中使用 cloudant 模块我已经读过环境变量可能是一个问题,但老实说我迷路了。我已经阅读了很多关于安装问题的帖子,但到目前为止没有任何效果......

我收到以下错误消息:

pi@rpi-2:~/hms/get-started-python $ pip install -r requirements.txt

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support

Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: Flask>=1.0.0 in /usr/lib/python2.7/dist-packages (from -r requirements.txt (line 1)) (1.0.2)
Collecting cloudant==2.13.0
  Using cached cloudant-2.13.0.tar.gz (60 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-d8SSO0/cloudant/setup.py'"'"'; __file__='"'"'/tmp/pip-install-d8SSO0/cloudant/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-7Btkkf
         cwd: /tmp/pip-install-d8SSO0/cloudant/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-d8SSO0/cloudant/setup.py", line 33, in <module>
        with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
    TypeError: 'encoding' is an invalid keyword argument for this function
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

更新: 所以这是我的代码:

from cloudant.client import cloudant

使用python3 code.py 运行我的代码我收到错误消息“

Traceback (most recent call last): File "code.py", line 1, in <module> from cloudant.client import cloudant ModuleNotFoundError: No module named 'cloudant'

虽然我不完全理解为什么将导入语句更改为 from cloudant import Cloundant 可以解决问题...

【问题讨论】:

  • 尝试将 python 更新到 python 3.x。

标签: python pip cloudant


【解决方案1】:

参数 encoding 在 Python 3.0 中添加到 open()setup.py 中的代码仅适用于 Python3,尽管包声明与 Python2 兼容。请注意they provide wheels 仅适用于 Python3。

使用encoding 是一个错误或声明与Python2 的兼容性是一个错误。哪一个由作者决定。 Report the problem 让他们解决。

或者试试 Python3。

【讨论】:

  • 所以我的代码只是 from cloudant.client import cloudant 并将该代码作为 python3 code.py 运行,我仍然得到模块未找到错误。我将编辑我的原始问题以包含代码和完整(新)错误消息....
  • 我的回答是关于第一个问题你最好不要包含第二个问题,而是创建一个不同的问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-07-07
  • 2021-08-02
  • 2019-02-12
  • 2017-04-27
  • 2016-03-03
  • 1970-01-01
  • 2011-08-20
相关资源
最近更新 更多