3

Trying to run "helloworld.py" in PyCharm 2020.2 which I thought I'd installed via Anaconda

this error appears in a few threads but the discussions are always about stuff that's a bit beyond a hello world program. I think it might be something to do with this PYTHONPATH thing but I don't understand where this is set (its not in Windows system environment variables), or who set it, or how to fix it.

C:\Users\DrMan\anaconda3\python.exe C:/Users/DrMan/AppData/Local/Programs/Python/Python39/helloworld.py Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH ='C:\Users\DrMan\AppData\Local\Programs\Python\Python39'
program name = 'C:\Users\DrMan\anaconda3\python.exe'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'C:\Users\DrMan\anaconda3\python.exe'
sys.base_prefix = ''
sys.base_exec_prefix = '' sys.executable = 'C:\Users\DrMan\anaconda3\python.exe'
sys.prefix = ''
sys.exec_prefix = ''
sys.path = [ 'C:\Users\DrMan\AppData\Local\Programs\Python\Python39', 'C:\Users\DrMan\anaconda3\python38.zip', 'C:\Users\DrMan\anaconda3', ] Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding Python runtime state: core initialized ModuleNotFoundError: No module named 'encodings'

Current thread 0x000098b8 (most recent call first):

Process finished with exit code 1

1
  • I also wonder if something weird has gone on and I've ended up with multiple installations IDLE runs this program fine from here (where the file is) C:\Users\DrMan\AppData\Local\Programs\Python\Python39 now I see in the error message a completely different python executable inside Anaconda. I must have cocked something up in the installation somehow. Commented Nov 28, 2020 at 8:33

2 Answers 2

2

In my case it was my root python 3.9 installation (used by my venv), that imported a file from my pycharm project (because my project was in PYTHONPATH).

The easiest way to solve the problem was to rename the file python was trying to import, so python would not find it anymore and fall back to the correct file in (my case) C:\python39.

Sign up to request clarification or add additional context in comments.

Comments

0

OK I found in the settings where I could change the Python Interpreter which I removed and added a link to the directory where i run IDLE and now it works.

If anyone has a good link/reference to understanding all this I would appreciate it. I am a beginner, so haven't really got into worrying about environments and packages and versions but I would like to "grok it" so I don't get into bad habits, like from the ground up how environments, packages and paths and settings are working.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.