gpt4 book ai didi

python - 路径库:无法从 'Sequence' 导入名称 'collections'

转载 作者:行者123 更新时间:2023-12-05 02:38:38 25 4
gpt4 key购买 nike

我重建我的项目已经有几天了,但是当我今天早上测试一些东西时,我想更新我的 Werkzeug 包,因为我的 Multidict 类有问题,我重建并开始收到这个错误:

#17 73.14     ERROR: Command errored out with exit status 1:
#17 73.14 command: /usr/local/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-0qw1gt47/pathlib_cc19f11e095d4bbd895469d77780e6c9/setup.py'"'"'; __file__='"'"'/tmp/pip-install-0qw1gt47/pathlib_cc19f11e095d4bbd895469d77780e6c9/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-908_ate4
#17 73.14 cwd: /tmp/pip-install-0qw1gt47/pathlib_cc19f11e095d4bbd895469d77780e6c9/
#17 73.14 Complete output (13 lines):
#17 73.14 Traceback (most recent call last):
#17 73.14 File "<string>", line 1, in <module>
#17 73.14 File "/usr/local/lib/python3.10/site-packages/setuptools/__init__.py", line 16, in <module>
#17 73.14 import setuptools.version
#17 73.14 File "/usr/local/lib/python3.10/site-packages/setuptools/version.py", line 1, in <module>
#17 73.14 import pkg_resources
#17 73.14 File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 23, in <module>
#17 73.14 import zipfile
#17 73.14 File "/usr/local/lib/python3.10/zipfile.py", line 19, in <module>
#17 73.14 import pathlib
#17 73.14 File "/tmp/pip-install-0qw1gt47/pathlib_cc19f11e095d4bbd895469d77780e6c9/pathlib.py", line 10, in <module>
#17 73.14 from collections import Sequence
#17 73.14 ImportError: cannot import name 'Sequence' from 'collections' (/usr/local/lib/python3.10/collections/__init__.py)
#17 73.14 ----------------------------------------
#17 73.14 WARNING: Discarding https://files.pythonhosted.org/packages/ac/aa/9b065a76b9af472437a0059f77e8f962fe350438b927cb80184c32f075eb/pathlib-1.0.1.tar.gz#sha256=6940718dfc3eff4258203ad5021090933e5c04707d5ca8cc9e73c94a7894ea9f (from https://pypi.org/simple/pathlib/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
#17 73.14 ERROR: Could not find a version that satisfies the requirement pathlib==1.0.1 (from versions: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.97, 1.0, 1.0.1)
#17 73.14 ERROR: No matching distribution found for pathlib==1.0.1

我试图在我的本地机器上安装依赖项 requirements.txt 并且它运行没有任何问题,但是当构建 docker 镜像时它出错了

Docker 文件:

FROM python:3

WORKDIR /usr/src/app

COPY . .

RUN pip install --no-cache-dir -r requirements.txt

EXPOSE 5010

RUN chmod u+x ./entrypoint.sh

要求.txt:

alembic==1.7.3
aniso8601==8.0.0
appdirs==1.4.4
artifactory==0.1.17
attrs==20.3.0
bcrypt==3.2.0
beautifulsoup4==4.9.3
bidict==0.21.3
blinker==1.4
boto3==1.18.50
botocore==1.21.50
bs4==0.0.1
cachelib==0.3.0
certifi==2020.12.5
cffi==1.14.5
chardet==3.0.4
click==8.0.1
cryptography==3.4.6
distlib==0.3.2
dnspython==1.16.0
dominate==2.6.0
email-validator==1.1.3
et-xmlfile==1.1.0
eventlet==0.30.2
filelock==3.0.12
Flask==2.0.1
Flask-Bootstrap==3.3.7.1
Flask-Login==0.5.0
Flask-Mail==0.9.1
flask-marshmallow==0.14.0
Flask-Migrate==3.1.0
Flask-RESTful==0.3.8
Flask-Session==0.4.0
Flask-SocketIO==5.1.1
Flask-SQLAlchemy==2.5.1
Flask-User==1.0.2.2
Flask-WTF==0.15.1
greenlet==1.1.0
gunicorn==20.1.0
idna==2.10
iniconfig==1.1.1
is-safe-url==1.0
itsdangerous==2.0.1
Jinja2==3.0.1
jmespath==0.10.0
Mako==1.1.5
MarkupSafe==2.0.1
marshmallow==3.12.2
marshmallow-sqlalchemy==0.26.1
numpy==1.21.0
openpyxl==3.0.7
packaging==20.9
pandas==1.2.5
paramiko==2.7.2
passlib==1.7.4
pexpect==4.8.0
pluggy==0.13.1
psycopg2-binary==2.9.1
ptyprocess==0.7.0
py==1.10.0
pycparser==2.20
PyNaCl==1.4.0
pyparsing==2.4.7
pytest==6.2.3
python-dateutil==2.8.1
python-dotenv==0.19.0
python-engineio==4.2.1
python-socketio==5.4.0
pytz==2021.1
requests==2.24.0
s3transfer==0.5.0
scp==0.13.3
shippo==2.0.2
simplejson==3.17.2
six==1.15.0
soupsieve==2.2
SQLAlchemy==1.4.15
SQLAlchemy-Utils==0.37.8
toml==0.10.2
urllib3==1.25.11
virtualenv==20.4.7
visitor==0.1.3
Werkzeug==2.0.2
WTForms==2.3.3
XlsxWriter==1.4.3

我还尝试将 pathlib 从需求文件中取出,以便其他依赖项可以自己安装它,尝试了多个版本的 pathlib,但它仍然出错:

#9 86.72 ERROR: Could not find a version that satisfies the requirement pathlib (from artifactory) (from versions: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.97, 1.0, 1.0.1)
#9 86.72 ERROR: No matching distribution found for pathlib

如有任何帮助,我们将不胜感激。

最佳答案

如果您查看基本图像,您会发现它刚刚在 27 小时前更新。

$ docker images python:3
REPOSITORY TAG IMAGE ID CREATED SIZE
python 3 618fff2bfc18 27 hours ago 915MB

事实上,从它的docker hubpython:3 标签现在指向 python 3.10.0,而不是几天前您编写 Dockerfile 时的 python 3.9

要解决由第三方库引起的任何不兼容问题,您最好再次将基础镜像降级为 python 3.9:

FROM python:3.9

关于python - 路径库:无法从 'Sequence' 导入名称 'collections',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69472308/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com