After successful pip3 install, I still get ModuleNotFoundError: No module named 'ConfigParser'
After successful pip3 install, I still get ModuleNotFoundError: No module named 'ConfigParser'
我正在安装一个复杂的 Python 软件项目。 5 个工程师为此工作了几年,但他们现在都走了,所以我需要自己解决这个问题。我运行:
/usr/local/bin/pipenv lock
我收到一长串错误,其中一个是:
ModuleNotFoundError: No module named 'ConfigParser'
所以我运行:
pip3 install ConfigParser
我得到:
Collecting ConfigParser
Downloading configparser-5.2.0-py3-none-any.whl (19 kB)
Installing collected packages: ConfigParser
Successfully installed ConfigParser-5.2.0
然后我重复:
/usr/local/bin/pipenv lock
我得到了完全相同的一组错误:
Locking [dev-packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success!
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✘ Locking Failed!
还有一长串看起来像这样的错误:
ERROR:pip.subprocessor:Command errored out with exit status 1:
command: /root/.local/share/virtualenvs/blueflow-c7ciKYpf/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pipenv-dmt2c0oj-build/psycopg2_75c2812bb7024f2aac1a6aa1c5c2cef9/setup.py'"'"'; __file__='"'"'/tmp/pipenv-dmt2c0oj-build/psycopg2_75c2812bb7024f2aac1a6aa1c5c2cef9/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'"'"'))' --no-user-cfg egg_info --egg-base /tmp/pip-pip-egg-info-35pnz9zt
cwd: /tmp/pipenv-dmt2c0oj-build/psycopg2_75c2812bb7024f2aac1a6aa1c5c2cef9/
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pipenv-dmt2c0oj-build/psycopg2_75c2812bb7024f2aac1a6aa1c5c2cef9/setup.py", line 225
except Warning, w:
^
SyntaxError: invalid syntax
----------------------------------------
ERROR:pip.subprocessor:Command errored out with exit status 1:
command: /root/.local/share/virtualenvs/blueflow-c7ciKYpf/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pipenv-dmt2c0oj-build/psycopg2_418a10a77a924c508bc796a1db4c47ae/setup.py'"'"'; __file__='"'"'/tmp/pipenv-dmt2c0oj-build/psycopg2_418a10a77a924c508bc796a1db4c47ae/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'"'"'))' --no-user-cfg egg_info --egg-base /tmp/pip-pip-egg-info-91fiybpm
cwd: /tmp/pipenv-dmt2c0oj-build/psycopg2_418a10a77a924c508bc796a1db4c47ae/
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pipenv-dmt2c0oj-build/psycopg2_418a10a77a924c508bc796a1db4c47ae/setup.py", line 50, in <module>
import ConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
----------------------------------------
CRITICAL:pipenv.patched.notpip._internal.resolution.resolvelib.factory:Could not find a version that satisfies the requirement psycopg2 (from versions: 2.0.10, 2.0.11, 2.0.12, 2.0.13, 2.0.14, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.3.2, 2.4, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.4.5, 2.4.6, 2.5, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.5, 2.6, 2.6.1, 2.6.2, 2.7, 2.7.1, 2.7.2, 2.7.3, 2.7.3.1, 2.7.3.2, 2.7.4, 2.7.5, 2.7.6, 2.7.6.1, 2.7.7, 2.8, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.8.5, 2.8.6, 2.9, 2.9.1, 2.9.2, 2.9.3)
[ResolutionFailure]: File "/usr/local/lib/python3.6/site-packages/pipenv/resolver.py", line 743, in _main
[ResolutionFailure]: resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
[ResolutionFailure]: File "/usr/local/lib/python3.6/site-packages/pipenv/resolver.py", line 711, in resolve_packages
[ResolutionFailure]: requirements_dir=requirements_dir,
[ResolutionFailure]: File "/usr/local/lib/python3.6/site-packages/pipenv/resolver.py", line 693, in resolve
[ResolutionFailure]: req_dir=requirements_dir
[ResolutionFailure]: File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 1385, in resolve_deps
[ResolutionFailure]: req_dir=req_dir,
[ResolutionFailure]: File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 1106, in actually_resolve_deps
[ResolutionFailure]: resolver.resolve()
[ResolutionFailure]: File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 884, in resolve
[ResolutionFailure]: raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: No matching distribution found for psycopg2
我认为 pipenv 使用的路径与 pip3
安装路径不同?我怎么知道?
我发现解决这个问题的唯一方法是在我的 .bashrc
文件中的 PATH 中添加越来越多的内容:
export PATH="$PATH:/root/.local/lib/python3.6/site-packages/:/usr/local/lib/python3.6/site-packages/"
export PATH="$PATH:/usr/local/bin/pipenv:/usr/local/bin/"
export PATH="$PATH:/root/.local/:/root/.local/bin/"
export PATH="$PATH:/root/blueflow/blueflow/bin/"
当然 ec2-user
也一样。
以 root 身份执行所有操作确实简化了一些问题,但当然也带来了很大的安全风险。
我正在安装一个复杂的 Python 软件项目。 5 个工程师为此工作了几年,但他们现在都走了,所以我需要自己解决这个问题。我运行:
/usr/local/bin/pipenv lock
我收到一长串错误,其中一个是:
ModuleNotFoundError: No module named 'ConfigParser'
所以我运行:
pip3 install ConfigParser
我得到:
Collecting ConfigParser
Downloading configparser-5.2.0-py3-none-any.whl (19 kB)
Installing collected packages: ConfigParser
Successfully installed ConfigParser-5.2.0
然后我重复:
/usr/local/bin/pipenv lock
我得到了完全相同的一组错误:
Locking [dev-packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success!
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✘ Locking Failed!
还有一长串看起来像这样的错误:
ERROR:pip.subprocessor:Command errored out with exit status 1:
command: /root/.local/share/virtualenvs/blueflow-c7ciKYpf/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pipenv-dmt2c0oj-build/psycopg2_75c2812bb7024f2aac1a6aa1c5c2cef9/setup.py'"'"'; __file__='"'"'/tmp/pipenv-dmt2c0oj-build/psycopg2_75c2812bb7024f2aac1a6aa1c5c2cef9/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'"'"'))' --no-user-cfg egg_info --egg-base /tmp/pip-pip-egg-info-35pnz9zt
cwd: /tmp/pipenv-dmt2c0oj-build/psycopg2_75c2812bb7024f2aac1a6aa1c5c2cef9/
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pipenv-dmt2c0oj-build/psycopg2_75c2812bb7024f2aac1a6aa1c5c2cef9/setup.py", line 225
except Warning, w:
^
SyntaxError: invalid syntax
----------------------------------------
ERROR:pip.subprocessor:Command errored out with exit status 1:
command: /root/.local/share/virtualenvs/blueflow-c7ciKYpf/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pipenv-dmt2c0oj-build/psycopg2_418a10a77a924c508bc796a1db4c47ae/setup.py'"'"'; __file__='"'"'/tmp/pipenv-dmt2c0oj-build/psycopg2_418a10a77a924c508bc796a1db4c47ae/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'"'"'))' --no-user-cfg egg_info --egg-base /tmp/pip-pip-egg-info-91fiybpm
cwd: /tmp/pipenv-dmt2c0oj-build/psycopg2_418a10a77a924c508bc796a1db4c47ae/
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pipenv-dmt2c0oj-build/psycopg2_418a10a77a924c508bc796a1db4c47ae/setup.py", line 50, in <module>
import ConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
----------------------------------------
CRITICAL:pipenv.patched.notpip._internal.resolution.resolvelib.factory:Could not find a version that satisfies the requirement psycopg2 (from versions: 2.0.10, 2.0.11, 2.0.12, 2.0.13, 2.0.14, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.3.2, 2.4, 2.4.1, 2.4.2, 2.4.3, 2.4.4, 2.4.5, 2.4.6, 2.5, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.5, 2.6, 2.6.1, 2.6.2, 2.7, 2.7.1, 2.7.2, 2.7.3, 2.7.3.1, 2.7.3.2, 2.7.4, 2.7.5, 2.7.6, 2.7.6.1, 2.7.7, 2.8, 2.8.1, 2.8.2, 2.8.3, 2.8.4, 2.8.5, 2.8.6, 2.9, 2.9.1, 2.9.2, 2.9.3)
[ResolutionFailure]: File "/usr/local/lib/python3.6/site-packages/pipenv/resolver.py", line 743, in _main
[ResolutionFailure]: resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
[ResolutionFailure]: File "/usr/local/lib/python3.6/site-packages/pipenv/resolver.py", line 711, in resolve_packages
[ResolutionFailure]: requirements_dir=requirements_dir,
[ResolutionFailure]: File "/usr/local/lib/python3.6/site-packages/pipenv/resolver.py", line 693, in resolve
[ResolutionFailure]: req_dir=requirements_dir
[ResolutionFailure]: File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 1385, in resolve_deps
[ResolutionFailure]: req_dir=req_dir,
[ResolutionFailure]: File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 1106, in actually_resolve_deps
[ResolutionFailure]: resolver.resolve()
[ResolutionFailure]: File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 884, in resolve
[ResolutionFailure]: raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
You can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: No matching distribution found for psycopg2
我认为 pipenv 使用的路径与 pip3
安装路径不同?我怎么知道?
我发现解决这个问题的唯一方法是在我的 .bashrc
文件中的 PATH 中添加越来越多的内容:
export PATH="$PATH:/root/.local/lib/python3.6/site-packages/:/usr/local/lib/python3.6/site-packages/"
export PATH="$PATH:/usr/local/bin/pipenv:/usr/local/bin/"
export PATH="$PATH:/root/.local/:/root/.local/bin/"
export PATH="$PATH:/root/blueflow/blueflow/bin/"
当然 ec2-user
也一样。
以 root 身份执行所有操作确实简化了一些问题,但当然也带来了很大的安全风险。