Ask coding questions

← Back to all posts
Is it possible to directly import Python packages from the console?
h
PaoloAmoroso

According to the Repl.it documentation it is possible to directly import a Python package by evaluating at the console the relevant import expression such as:

However, when I do it in any of my Python 3 REPLs I get a module not found error:

This happens in all REPLs, including freshly created ones, and with all packages. The only way I can install a package is by using the REPL’s package manager via a requirements.txt file.

What am I doing wrong?

Voters
akaywood
PaoloAmoroso
Comments
hotnewtop
PaoloAmoroso

Thanks all, I misunderstood how package installation is supposed to work. By the way I can import packages from the Python console, but only system and local ones such es import sys.

ash15khng

You need to use a requirements.txt file to let repl.it know you are using that package. It's not really possible for repl.it to download every single package on pypi.

FellowHashbrown

It works just fine for me. I tried it multiple ways.
I imported it from the main.py file.
I imported it from another file, test.py file.
I don't think you can import it directly from the console.
You would have to have the import statement in a file. Then it will install.