Module not found error even though it shows as installed in python interpreter settings

I have an example sycript that uses LinkedList module

It is imported in the .py scrip via

from LinkedList import *

the editor shows this as not installed, and when I run the script it also throws a "module not found" error

I then (re-)installed the LinkedList module via right-click actions menu and it says that it got successfully installed.

Checking in the settings - python interpreter dialog, the module gets listed with latest version (no upgrade symbol)

Nevertheless, on run, the "module not found" error persists. As well as the red wiggly line int he editor.

 

I have this issue on an existing installation of PyCharm on Xubuntu recently upgraded to 22.04

The script worked well before the Xubuntu upgrade

I also can reproduce this issue on a completely fresh install of PyCharm running in VirtualBox Xubuntu 22.04 VM.
Here the above import statement is the only content of the test script

7 comments
Comment actions Permalink

Could you please provide a link to the homepage of the module in question? Is it https://github.com/teroqim/linkedlist by any chance? 

Some python modules are imported by the different name than they were installed. Just to check if the issue is IDE-related, I assume it's also reproduced if you run it from the terminal outside of the IDE?

0
Comment actions Permalink

I have no idea where this module comes from. It is installed via PyCharm. Is there a way to check this on the installed module?

I am very new to this and up to now, I never had to bother about settings, all just worked (which in a way is a nice compliment to pyCharm ;) ).

As far as I have understood the concept behind the venv, it will never run in the terminal because all the modules etc are project specific and only available in the chosen interpreter. But I'll happily learn that I am wrong :)

And, with the exactly same code, it worked before the Xubuntu upgrade

0
Comment actions Permalink

The easiest way to check if the issue is IDE-related is to run your code from the terminal. If the issue repeats, unfortunately we can't do anything about it from the IDE side, so referring to the module's documentation is recommended.

0
Comment actions Permalink

just to be sure I do it right:
I navigate to the folder where my test-script is located, go to the venv folder in there,  and run the command

python3 ../test.py

 

well, as you predicted, the error persists!

May I ask how I can find out which module PyCharm installs when it does so by resolving the import statement?
How can I find out from where it downloaded the module?

0
Comment actions Permalink

The correct way is to activate the venv in the terminal first, and then run it with `python /path/to/the/script.py`

More information about creating and activating a python virtual environment in the terminal can be found at https://docs.python.org/3/tutorial/venv.html

May I ask how I can find out which module PyCharm installs when it does so by resolving the import statement?
How can I find out from where it downloaded the module?

To proceed, I would suggest finding the package in the repository and check if it has installation instructions or a link to the home page. There you may find hints about the correct usage of the package.

0
Comment actions Permalink

Thank you for the detailed explanation and the link to the tutorial. Learned a lot!

And sorry to bother you again with my ignorance, but what and where is "the repository"?

I went to the python interpreter settings, and there a double-click on any installed package brings up a very long list of available packages. In the description that is displayed there I find the links.

Is this what you call repository?

 

Anyhow, to come back to the initial problem:
I tried different modules (pandas, numpy, beautifulsoup) and they all work in Pycharm and in the terminal.
So you were right that the problem is with the imported module "LinkedList" itself.
Now I know where to look for troubleshooting :)

0
Comment actions Permalink

PyCharm contacts the remote repository to download and install packages. More info about the repository -- https://en.wikipedia.org/wiki/Python_Package_Index

0

Please sign in to leave a comment.