Ask coding questions

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

According to the 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?


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.


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


It works just fine for me. I tried it multiple ways.
I imported it from the file.
I imported it from another file, 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.