demjson 设置命令出错:use_2to3 无效

问题描述 投票:0回答:1

我在 Google 云函数上下载 Python 代码的要求时遇到错误。我已经在网上查找了该错误,并尝试了我能找到的所有方法,看看是否可以修复它,但没有任何效果。 我读到,尝试在 python 3 上运行 python 2 的代码时会出现此错误,但我使用的代码是相当新的,我认为这不应该是问题所在。 我从Github获得的代码:https://github.com/togobingi/google_cloud_function/blob/master/ftp_to_bq_cloud_function.py 我还发现这个“use_2to3”错误与setuptools的版本有关。我尝试将我的 setuptools 设置为 58 之前的版本,但仍然没有修复。

我是否配置错误?有人知道我该如何解决这个问题吗?

以下是要求:

python-csv==0.0.11
requests==2.13.0
wget==3.2
DateTime==4.3
regex==2019.11.1
python-consul>=0.7.2
timeout-decorator>=0.4.0
hgijson>=1.5.0
demjson>=2.2.4
demjson3>=3.0.5
munch>=2.2.0
setuptools==57.5.0

这是我收到的错误:

  Downloading google_cloud_bigquery-1.22.0-py2.py3-none-any.whl (161 kB)
Collecting python-csv==0.0.11
  Downloading python-csv-0.0.11.tar.gz (26 kB)
Collecting requests==2.13.0
  Downloading requests-2.13.0-py2.py3-none-any.whl (584 kB)
Collecting wget==3.2
  Downloading wget-3.2.zip (10 kB)
Collecting DateTime==4.3
  Downloading DateTime-4.3-py2.py3-none-any.whl (60 kB)
Collecting regex==2019.11.1
  Downloading regex-2019.11.1.tar.gz (669 kB)
Collecting python-consul>=0.7.2
  Downloading python_consul-1.1.0-py2.py3-none-any.whl (24 kB)
Collecting timeout-decorator>=0.4.0
  Downloading timeout-decorator-0.5.0.tar.gz (4.8 kB)
Collecting hgijson>=1.5.0
  Downloading hgijson-3.1.0.tar.gz (22 kB)
Collecting demjson>=2.2.4
  Downloading demjson-2.2.4.tar.gz (131 kB)
    ERROR: Command errored out with exit status 1:
     command: /layers/google.python.pip/pip/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-yawlu8vs/demjson/setup.py'"'"'; __file__='"'"'/tmp/pip-install-yawlu8vs/demjson/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-0qwjfyxi
         cwd: /tmp/pip-install-yawlu8vs/demjson/
    Complete output (1 lines):
    error in demjson setup command: use_2to3 is invalid.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
python python-3.x google-cloud-functions
1个回答
0
投票

您遇到的 demjson 问题与其对 use_2to3 的过时依赖有关,最新版本的 setuptools 不再支持该依赖。

您可以使用 demjson3 代替 demjson,它是 demjson 的一个分支,并且与最新的 Python 版本兼容。

以下是安装demjson3的步骤:

  1. 卸载任何现有的 demjson 包(如果已安装):
pip uninstall demjson
  1. 安装demjson3:
pip install demjson3

这应该可以解决您的安装问题,并允许您使用 demjson3 解析 JSON。

© www.soinside.com 2019 - 2024. All rights reserved.