Replit’s package manager, UPM, does import guessing by default. (This can be turned off.)
However, in python, attempting to import one’s own modules may cause UPM to think that some random external package is needed, which is problematic for more common file names.
Also, some packages do have different names than their imports, which UPM can miss. (It is possible to specify the exact package.)
This also affects unit tests, which are broken because of import guessing.
Do not auto-install packages for import names that already exist.
It is not possible to cancel the package installation from the console. Also, package installation often fails or takes a very long time.
Steps to reproduce:
Create any python repl, then put
import main or
from model import * in a python file. It does not matter whether
model.py exists. The packager will auto-install regardless. (In this case, package installation will take so long that the repl can never be run.)
Examples of some problematic common names are here. The most problematic I think are
This auto-installation often causes confusion and frustration (users might not know what the packager output in the console means or how to turn it off), leading to many problems and bugs.
Poetry version solving failed
Failed to add packages, reverting the pyproject.toml file to its original content. exit status 1
Error installing dependencies
Python: having a file called "model.py" gets stuck installing gardenlinux
Unit tests not working on new forks: Error refers to installation of git-python
Packager Failed to Install on Teams
Disabling automatic package guessing and installing
Unnecessary packages automatically installed
How do I disable replit guessing packages
Disable automatic pip install
How to stop replit guessing packages in Python template
Python: Problem with new template
Python repl loads an incorrect package
I am aware of the two, undocumented, relatively recent configuration variables that can be added to
.replit file (absent by default) to disable import guessing, which were made to replace the now defunct
[packager] configuration. But many people don’t know about this.
- if the import exists, don’t install it
- expose the configuration for disabling import guessing in the Packages tool in the editor
- add better Packager console output for auto-installing (people are often confused why
poetry add git-pythonis showing up when they run their repl)
- when guessing packages, tell user what import name caused that package to be auto-installed
- add an easy way to cancel automatic package installation in console
- update repl configuration documentation, including for outdated packager configuration
- fix unit tests