module not found error (in pycharm)

I am trying to teach myself python. Using Windows 10 and the latest python as of July 2020. I installed anaconda and was able to run python code in the Jupyter notebook. It was able to find matplotlib, numpy, and other modules, both within Jupyter and at the anaconda prompt. But I am stubbornly insisting on using Pycharm. So I open pycharm and pycharm cannot find those modules. I opened pycharm in two ways (clicking on the desktop icon, and simply typing "pycharm" at the anaconda prompt). Doesn't matter. pycharm can't find modules either way.   

I have read through a similar post "Module not found in PyCharm but externally in Python". There are numerous suggestions there. But none of them are really simple and straightforward. I know from using many other languages that there must be a simple and straightforward way that doesn't involve arcane BS like creating an virtual environment.  

 

3 comments
Comment actions Permalink

Modules are typically installed for specific interpreters, be it the virtual environment interpreter or global system interpreter. You need to find out which interpreter you have used in Jupyter Notebook web app, and setup this interpreter in PyCharm. Another way is to start Jupyter server where you know the modules are working, then connect to this server from PyCharm.

More info about managing Jupyter servers in PyCharm: https://www.jetbrains.com/help/pycharm/configuring-jupyter-notebook.html

0
Comment actions Permalink

Thanks for you explanation Andrey. It helped my understanding, although by the time you answered I already figured out how to get Sublime+Kite to do everything I needed for the time being. 

This experience certainly has left me in awe of how convoluted and arcane python-related packages have managed to make this. Every forum is teeming with desperate souls with questions related to "module not found" issues. In my nearly forty years in the game, I've never run into anything like it. Look at your first paragraph. I know you're right, but it is ludicrous.  

0
Comment actions Permalink

I agree that Python packaging ecosystem is somewhat convoluted and it was certainly true some years ago, but nowadays I think it's quite straighforward with tools like virtualenv (https://virtualenv.pypa.io/en/latest/) and pip. Getting basics of virtualenv will allow you to manage multiple python environments with ease.

0

Please sign in to leave a comment.