Search code examples
pythonpycharmidearcgispython-idle

Import packages works in idle.exe but not in IDE (python)


Please note that I am a complete beginner and installed python simply by going to the website and clicking "install". It used to work fine.

Now suddenly I have this frustrating situation where I can run just about anything in the idle.exe found in the scripts section of arcgispro, but cannot run the same .py file in an IDE. As a beginner this is obviously a headache as I would like auto code formatting, suggestions, etc. Literally any IDE would be fine (spyder, pycharm). The problem is that every single time there is some kind of error with the package imports. e.g. from pycharm:

import shapefile ModuleNotFoundError: No module named 'shapefile'

It's not just shapefile... this is happened at random times with numpy and also matplotlib.

When I look at "Installed Apps" on windows, it just says Python 3.10.0 and Python Launcher. No, there is no file that I created called "shapefile.py" A lot of solutions suggest things with pip... I have absolutely no idea what pip is...is it installed program? where do I find that?

EDIT: I just found out that the system paths of the two are different so this explains why one works but the other doesn't... but how can I make it so that the IDE would work?


Solution

  • Ok, simple answer:

    In Pycharm, go to the bottom pycharm bar and click on Python Console. Then type pip install pyshp. Voila! Assuming it works for other packages as well. Still do not know where to make pycharm work with the other environment...