You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Replit运行按钮误装错误Python包致项目崩溃,如何阻止?

Replit依赖自动安装错误问题

问题详情

  • 运行Replit项目BugImportDecoupleHumps时,系统自动执行未触发的poetry命令:
--> poetry add decouple humps
Using version ^0.0.7 for decouple
Using version ^0.2.2 for humps

Updating dependencies
Resolving dependencies...

Package operations: 2 installs, 0 updates, 0 removals

  • Installing decouple (0.0.7)
  • Installing humps (0.2.2)

Writing lock file
  • 项目的pyproject.toml已配置正确依赖:
[tool.poetry.dependencies]
pyhumps = "3.8.*"
python-decouple = "^3.6.0"
  • Replit的UPM会错误猜测依赖,安装了错误的decouple和humps包,导致每次运行代码报错:
Traceback (most recent call last):
  File "/home/runner/BugImportDecoupleHumps/main.py", line 2, in <module>
    from decouple import config
ImportError: cannot import name 'config' from 'decouple' (/home/runner/BugImportDecoupleHumps/.pythonlibs/lib/python3.11/site-packages/decouple/__init__.py)
  • 手动卸载错误包并清理pyproject.toml中的多余行后,直接从shell运行代码可正常执行:
~/BugImportDecoupleHumps$ pip uninstall decouple humps
Found existing installation: decouple 0.0.7
Uninstalling decouple-0.0.7:
  Would remove:
    /home/runner/BugImportDecoupleHumps/.pythonlibs/lib/python3.11/site-packages/decouple-0.0.7.dist-info/*
    /home/runner/BugImportDecoupleHumps/.pythonlibs/lib/python3.11/site-packages/decouple/*
Proceed (Y/n)? 
  Successfully uninstalled decouple-0.0.7
Found existing installation: humps 0.2.2
Uninstalling humps-0.2.2:
  Would remove:
    /home/runner/BugImportDecoupleHumps/.pythonlibs/lib/python3.11/site-packages/humps-0.2.2.dist-info/*
    /home/runner/BugImportDecoupleHumps/.pythonlibs/lib/python3.11/site-packages/humps/*
    /home/runner/BugImportDecoupleHumps/.pythonlibs/lib/python3.11/site-packages/tests/*
  Would not remove (might be manually added):
    /home/runner/BugImportDecoupleHumps/.pythonlibs/lib/python3.11/site-packages/humps/__init__.pyi
    /home/runner/BugImportDecoupleHumps/.pythonlibs/lib/python3.11/site-packages/humps/main.py
    /home/runner/BugImportDecoupleHumps/.pythonlibs/lib/python3.11/site-packages/humps/main.pyi
    /home/runner/BugImportDecoupleHumps/.pythonlibs/lib/python3.11/site-packages/humps/py.typed
Proceed (Y/n)? 
  Successfully uninstalled humps-0.2.2
~/BugImportDecoupleHumps$ python main.py 
hello False

求助

如何解决这个问题?能否阻止Replit自动猜测并安装错误的依赖包?


内容的提问来源于stack exchange,提问作者mblakele

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 00:45:10