How to stop replit guessing packages in Python template

Hello,

I’ve noticed the format of .replit file changed to TOML since the last time I used it (Python repl loads an incorrect package - Support / Bug Reports - Replit Ask).

Now it doesn’t seem I can disable guessing imports.

I have the following in .replit file:

entrypoint = "main.py"
modules = ["python-3.10:v18-20230807-322e88b"]

hidden = [".pythonlibs"]

[nix]
channel = "stable-23_05"

[deployment]
run = ["sh", "-c", "python3 main.py"]

[packager]
language = "python3"
ignoredPackages = ["flet-pyodide"]

[packager.features]
packageSearch = false
guessImports = false

and yet replit keeps installing flet-pyodide package when running repl.

What am I doing wrong?

3 Likes

you are not doing anything wrong what has happened is replit made it different maybe research whats goin g on

1 Like

One way to prevent Replit from auto-installing packages is to run this in Shell:

I’m not certain, but this may break the packager. Even if it does, you can always just use poetry directly from the Shell.

4 Likes

The configuration doesn’t work so you’ll have to either:

1 - If possible, tell upm explicitly which package to import with a comment

import pygame  #upm package(pygame-ce)

2 - Break upm so it can’t guess anything (also disables packager tab)
Either use the shell command or delete the contents of .upm/store.json to break upm.

1 Like

Replit will just restore it because it thinks you are doing “destructive actions” and it is trying to “help you” but it is not helpful at all.

2 Likes

It doesn’t look like UPM restores the cache. It’ll only do that if you delete the entire file.

Import comment worked like a charm, thank you!

import flet as ft  #upm package(flet)
1 Like

The configuration for import guessing has been fixed: