Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot run program (python) No such file or directory

Tags:

python

pycharm

I was given a code at school to modulate for a research project, but first I would like to run it as it is, unmodulated. Its written in Python, and I use Pycharm CE on Ubuntu 18.04 with Python 2.7 ... I've chosen the correct interpreter in the project settings (I think. The path is /usr/bin/python2.7) and I get this Error Message:

Error running 'project': Cannot run program "C:/WinPython-64bit-2.7.9.1/python-2.7.9.amd64/python.exe" (in directory "/home/user/Documents/model"): error=2, No such file or directory

Why is Pycharm still looking for the Interpreter in the folder that, I'm assuming, the user before me used to put it?

like image 370
cheesus Avatar asked Jun 07 '18 20:06

cheesus


People also ask

Can t open file No such file or directory python?

The Python "FileNotFoundError: [Errno 2] No such file or directory" occurs when we try to open a file that doesn't exist in the specified location. To solve the error, move the file to the directory where the Python script is located if using a local path, or use an absolute path.

Why does PyCharm Say No such file or directory?

That error is most likely related to your program, not the IDE. Chances are you need to specify where to find the file, otherwise it defaults into the current directory. One easy fix is to copy the file to open into the same directory as your Python program, then run it.

Why is my python file not running in PyCharm?

In PyCharm, open the Settings dialog Ctrl+Alt+S , navigate to Project < project name> | Python Interpreter. nearby the Python Interpreter field and select Show All.... The interpreter you use in your project will be selected in the list of the available interpreters. and copy the path from the Interpreter path field.

How do I fix invalid Python interpreter in PyCharm?

Do one of the following: Click the Python Interpreter selector and choose Add New Interpreter. Press Ctrl+Alt+S to open the project Settings/Preferences and go to Project: <project name> | Python Interpreter. Click the Add Interpreter link next to the list of the available interpreters.


1 Answers

You can fix this error by modifying the .idea/workspace.xml file. Search and remove any old interpreters and put the correct one.

Answer inspired by Ryan Elfman's post: https://intellij-support.jetbrains.com/hc/en-us/community/posts/206597295-Why-can-t-I-run-a-script-in-PyCharm-when-I-can-debug-it-I-get-CreateProcess-error-123

like image 181
gcamargo Avatar answered Oct 02 '22 20:10

gcamargo