0

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?

Anna1
  • 11
  • 4
  • You can tell PyCharm which Python installation to use for a project in File | Settings | Python interpreter. If you install a new version of Python after creating a project, that project will go on using the old one until you tell it otherwise. That may explain why the behaviour appears to be random. Your could have found this out for yourself: Help | Find action | "interpreter". – BoarGules Feb 07 '22 at 09:53
  • @BoarGules actually I couldn't have found this out for myself because I don't understand what's going on and I obviously didn't know there was a problem with the interpreter. As far as trying to change the interpreter in pycharm... do I just navigate to the idle.exe file that is working? – Anna1 Feb 07 '22 at 11:45
  • Not `idle.exe`: `python.exe`. – BoarGules Feb 07 '22 at 12:46
  • See the Python documentation section [4.9 Finding modules](https://docs.python.org/3/using/windows.html#finding-modules)... Yes, there's a bunch of rules to it. Notice two rules: 1º the activated venv (where pip install packages to) is added to the Path. 2º The directory where you execute Python from is also added to the Path. Having said that, if you're uncertain use `import sys` and look inside `sys.path` to see what's been added. Using the IDE you can use `mark as sources root` to add something to the Path. – bad_coder Feb 08 '22 at 19:03
  • 1
    Does this answer your question? [Unresolved reference issue in PyCharm](https://stackoverflow.com/questions/21236824/unresolved-reference-issue-in-pycharm) – bad_coder Feb 08 '22 at 19:04

1 Answers1

0

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...

Anna1
  • 11
  • 4