安装dotenv时出现‘error: invalid command 'dist_info'’错误求助
解决pip安装dotenv时的依赖错误问题
问题原因
你尝试安装的dotenv是一个已废弃的老旧包(版本0.0.5,最后更新于2013年),它依赖的distribute工具早已被淘汰,无法兼容现代版本的pip,因此导致安装过程中出现pip subprocess to install backend dependencies did not run successfully错误。
解决方法
- 安装正确的主流包:你需要的环境变量管理功能,应该使用目前活跃维护的
python-dotenv包,执行以下命令安装:pip3 install python-dotenv - 清理旧包(可选):如果之前已经尝试安装过废弃的
dotenv包,先卸载它避免冲突:pip3 uninstall dotenv - 验证使用:安装完成后,你可以在代码中通过
from dotenv import load_dotenv调用功能,和你原本预期的dotenv包用法完全一致。
完整错误日志
Collecting dotenv Downloading dotenv-0.0.5.tar.gz (2.4 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... error error: subprocess-exited-with-error × pip subprocess to install backend dependencies did not run successfully. │ exit code: 1 ╰─> [30 lines of output] Collecting distribute Downloading distribute-0.7.3.zip (145 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 145.4/145.4 kB 224.2 kB/s eta 0:00:00 Installing build dependencies: started Installing build dependencies: finished with status 'done' Getting requirements to build wheel: started Getting requirements to build wheel: finished with status 'done' Preparing metadata (pyproject.toml): started Preparing metadata (pyproject.toml): finished with status 'error' error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [6 lines of output] usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: setup.py --help [cmd1 cmd2 ...] or: setup.py --help-commands or: setup.py cmd --help error: invalid command 'dist_info' [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details. [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error × pip subprocess to install backend dependencies did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip.
内容的提问来源于stack exchange,提问作者helloworldIwanttocode
相关产品推荐
相关产品推荐

