Public replit:
https://replit.com/@mblakele/BugImportDecoupleHumps
When I run this replit, I see a poetry command that I haven't requested:
--> 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
I think this is a result of replit upm searching for decouple
and humps
, which my pyproject.toml
already specifies:
[tool.poetry.dependencies]
pyhumps = "3.8.*"
python-decouple = "^3.6.0"
But because replit guesses anyway, and gets it wrong about these packages, every run fails with:
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)
After each attempt, I have to remove extraneous lines from my TOML and also use pip or upm to remove the bogus packages. If I do this, running the code from shell works ok:
~/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
How can I fix this? Can I stop replit from guessing about these packages?
Thanks in advance for any help!
Workaround:
Remove any unwanted packages. Run poetry install
in the replit shell. Then add deliberately broken lines to pyproject.toml
so that replit can’t run its own install.
[tool.poetry.dependencies]
decouple = "^666.42.69" # replit bug workaround
humps = "^666.42.69" # replit bug workaround
This is crude but works around the problem within replit’s development environment. Remove the fake dependencies before deploying in other environments.