公开转发:
https://replit.com/@mblakele/BugImportDe CoupleHumps
当我运行这个 replit 时,我看到一个我没有请求的诗歌命令:
--> 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
我认为这是 replit upm 搜索
decouple
和 humps
的结果,我的 pyproject.toml
已经指定了:
[tool.poetry.dependencies]
pyhumps = "3.8.*"
python-decouple = "^3.6.0"
但是因为 replit 无论如何都会猜测,并且对这些包的理解是错误的,所以每次运行都会失败:
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)
每次尝试后,我都必须从 TOML 中删除无关的行,并使用 pip 或 upm 删除伪造的软件包。如果我这样做,从 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 猜测这些包吗?
预先感谢您的帮助!
您可以尝试在 main.py 右侧的 shell 中运行
poetry remove python-decouple