Asier R.
Asier R.

Reputation: 503

PyCharm doesn't detect interpreter

I want to use PyCharm, so I downloaded and installed it (v. 4.5, community edition). I had previously installed Python 3.5 64-bit from python.org (I'm using Windows 10).

To start using PyCharm, I need a project interpreter, which I can select in the settings. As far as I'm concerned, the interpreter is "py.exe", but when I select it, I get this error message:

"The selected file is not a valid home for Python SDK".

I also tried to use every file whose name contained "python" or "py", and failed.

On every website and video I see, they select a file called "python.exe", but they're using Python 3.4 or a previous version. I checked that PyCharm supports 3.5 ("Initial support for Python 3.5").

Is there anything I'm doing wrong?

Upvotes: 22

Views: 74829

Answers (10)

Eyal
Eyal

Reputation: 53

I wanted to add python 3.13. This is a bit of dirty hack, but I was able to do it by redirecting a version that was properly installed and which I don't use (Python 3.6) to python 3.13.

mv Python36 Python36x
cmd /C "mklink /d Python36 C:\Users\XXX\.pyenv\pyenv-win\versions\3.13.0"

Then selecting Python36 on pycharm.

By running procmon , I saw that it does scan my folder (3.13), but somehow refused to add it to the options.

Upvotes: 0

The solution might be to remove invalid environments and those with the same name as the current project. It happened to me when I had cca 15+ environments (most of them unused).

The workaround is to

  1. go to Settings -> Project: [your project] -> Python Interpereter
  2. in the menu with all interpreters, choose "Show all"
  3. unclick the filter icon at the top left
  4. remove invalid interpreters or those with the same name as your project
  5. try to add your new environment again

Then it should be automatically listed as option in your run configuration.

Upvotes: 0

Alvaro
Alvaro

Reputation: 101

I faced the same problem in MAC and the issue was that I am running the project from a USB, including the virtual env folder. As soon as I moved it into the hard drive, everything worked fine.

Upvotes: 0

CVname
CVname

Reputation: 347

For me the following solution it worked:

My configuration: Pycharm Community edition 2019.1.1 Anaconda distribution with python 3.7. Interpreter in standard location.

Problem: Pycharm was not able to find python interpreter after reinstallation of anaconda distribution.

Solution: - Make sure you run pycharm as admin (right click and run as admin). This was actually the critical step. - Create new project (or open an existing one) - Depending on the choice choose interpter or go to file > settings > project interpreter > choose small gear on rights side > add > on base interpreter choose the 3 dots > paste the location of the interpreter in the anaconda distribution.

Hope it helped someone. For me the blocking point was that for some reason pycharm was not launching with admin rights.

Blockquote

Upvotes: 0

DonkeyKong
DonkeyKong

Reputation: 1093

file > new project settings > project Interpreter > click in the drop down and select 'show all' > click the '+' button >

Now, in the Virtualenv Environment tab under the New environment radio button, check the path in the 'Base interpreter:' field. For me, mine was set to an invalid path. Once I had corrected the path to point to python.exe I recreated my new project and PyCharm built the virtualenv.

For me there was a bit more too.... When creating the new project I expanded the drop down and had to verify the directory where the venv directory was being created. Once I had corrected the path here I had to click around a bit to get it to let me create the project.

I'm going to chaulk this up to a bug. I'm using Community edition.

Upvotes: 15

Waseem A
Waseem A

Reputation: 21

PyCharm project interpreter problem Resolved
I installed anaconda python distribution (Anaconda3-5.0.1-Windows-x86_64.exe) from the anaconda website. https://anaconda.org/anaconda/python
What it actually did was it re-installed my Python3.6.3 (pertinent to mention I have windows10, with pyCharm community & python 3.5 already but with the interpreter problem and while installing anaconda I chose the following settings and disabled my antivirus before my anaconda installation):

  1. selecting allow for all users
  2. installation path was set correctly and (stored safely for future)
  3. restart my Computer after installation.(not essential-but I did)
  4. opened Anaconda & Jet brian pycharm
  5. selected new project in PyCharm screen shot of my New project default Python interpreter location = C:\Users\Skboy\PycharmProjects\dani Interpreter = C:\Users\Skboy\AppData\Local\Programs\Python\Python36-32\python.exe

Wow! my pyCharm started working for me,

Resolution : Python6.3 re-installation with proper custom setting

make a python test test1.py program file to print "hello python test world"

Run

now my Python Interpreter(automatically -by default select) Python 3.6.3
edit configuration & check for interpreter

(C:\Users\user1\AppData\Local\Programs\Python\Python36-32\python.exe)

Run
success test Run
worth to mention Anaconda Jupyter is a web based can also be used in case novice user are still having problems

Upvotes: 2

Haris Ghauri
Haris Ghauri

Reputation: 597

If you kept the default settings while installing python, Your project interpreter for PyCharm will be:

C:\Users\yourUserName\AppData\Local\Programs\Python\Python36\python.exe

Chose the above location as your project interpreter inside PyCharm.

Depending on which python version you have, it could be either Python36\python.exe or Python35\python.exe.

Upvotes: 0

Anmol G
Anmol G

Reputation: 191

I faced a Similar issue and was not able to find Python interpreter anywhere on the system.

The problem with it was that python was installed directly with default settings and there was no exe found in

C:\Python35\ 

and to solve this i tried uninstalling and reinstalling with custom settings and selecting allow for all users as well which did the trick and path was set correctly to

C:\Python35\python.exe.

After whichPycharm was able to detect the interpreter on this path.

Upvotes: 2

Ben Sharman
Ben Sharman

Reputation: 11

I have had the exact same problem and was unable to find the solution until just now. Hopefully this works for anyone that was struggling with it.

I went to the location of the Python 3.5 (32-Bit) in my C: Drive which it turns out is just a shortcut to the actual Python application, right click on it and select Open file location which should direct you to the application version of python - simply called 'python'. This is the .exe file that PyCharm was looking for to use as the interpreter.

Now go to the configure interpreter menu in Pycharm and type in the file location of the actual python application. To get to mine I had to go to AppData/Local/Programs/Python/Python35-32. Click on the python.exe file and it should work.

This is my first post here so if its formatted incorrectly or doesn't use the conventional terms - sorry. Let me know if the solution worked for anyone else with the problem or if I fluked it.

Upvotes: 1

xponent
xponent

Reputation: 191

When creating a project in PyCharm, if the interpret is not already selected, in the drop down menu under the projects "Location:", you can click the gear-looking icon to the right of the interpreter option, and click "Add Local"; then select the file location of the python.exe file that you have installed. It will probably be C:\Python35\Python.exe

Upvotes: 4

Related Questions