I just had this error and got around it, and long-story-short I think it may have had to do with my PATH / PY_HOME / PYTHONPATH environment variables pointing to a different version of Python. Here's what I did:
Background:
- In my case, I was trying to get a Python 2.7 venv running on a laptop where I'd previously been working with Python 3.
- I'm using Windows 7.
Solution:
- Hit the Windows key to pop up the Start menu.
- Type out 'path' and hit Enter.
- The 'Environment Variables' window should appear.
- There should be two sections of the window:
- One should say, "User variables for your_user_name".
- The other should say "System variables".
- In both sections of the window, look for and edit (if they exist) the PATH, PYTHONPATH, and PY_HOME environment variables.
- I removed any references to Python 3.
- I set the PY_HOME variable to C:\Python27 (or whatever the path is to the Python installation you're trying to get working in PyCharm.)
- I also deleted my installation of Python27 and reinstalled it, but I'm not sure that that was necessary.
- Restart PyCharm.