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

0
9 comments

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

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

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

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

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

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

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

0

I found this issue that packages were not missing when running my script at the command line, yet missing when trying to debug with the IDE.  To fix this, I did `pip freeze > requirements.txt` then opened requirements.txt in the IDE.

I noticed squiggly lines under certain packages. Hovering over it, I got the lightbulb icon to see the issue and suggested fixes. The IDE told me the package was not installed. I confirmed it was installed in the venv using `python -m pip list`.

However, there is definitely a discrepancy because when I open the “Project Structure” window in the IDE, and go to the Packaged tab, I see its missing there.

So back to the requirements file, that I am viewing in the IDE, I just click on the suggested fix which it to install the “missing” package.

Clearly the IDE is not using the packages from the venv. I have no idea what its doing or where its looking. Maybe someone at Jetbrains can clarify please.

0

Hi Jetbrains, I am wondering which version of the IDE you are dealing with? What are the package names PyCharm complains about?

Does it look similar to PY-70173? As a general troubleshooting step, please try updating to the recent 2024.3.1.1 version  and check if the issue persists on it.
 

0

Please sign in to leave a comment.