When the name of the package does not match the name of the imported module, the wrong package is installed

Bug description:
When the name of the package does not match the name of the imported module, the wrong package is installed.

It is possible to manually install the correct package, but the code editor keeps showing the red wiggle. For example, after running the following in the shell, the code shown below works, but the red wiggle is still visible:

pip uninstall anvil
pip uninstall anvil-uplink
pip install anvil-uplink

Expected vs Current Behavior:

  1. The correct package should be installed.
  2. The red wiggle should disappear when the import succeeds.

Steps to reproduce:
Create a new python repl, add the following code and run:

import anvil
import anvil.server
print(anvil)
print(anvil.server)

Bug appears at this link: https://replit.com/@stenci/InbornWealthyGigabyte#main.py

Browser/OS/Device: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36

Replit Profile: https://replit.com/@stenci

Hello, auto-importing is an intended feature of UPM (Universal Package Manager). In python specifically, these guessed imports may be wrong, so you should tell it which package to import.
Example:

import pygame  #upm package(pygame-ce)

Related:


It is usually best to disable import guessing in the packager configuration in .replit file, but unfortunately this is currently broken because of a bug.


4 Likes

@stenci for you it would be

import anvil  #upm package(anvil-uplink)
2 Likes

This is a tad bit of a nuclear option, but it does work:

1 Like

Replit has released a new setting to disable installs or guessing in configuration:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.