Home > Net >  Python - FileNotFoundError: [Errno 2] when writing to file with 'w ' in Linux
Python - FileNotFoundError: [Errno 2] when writing to file with 'w ' in Linux

Time:10-30

My program works perfectly on Windows but I'm trying to use it on Linux now and the same code produces a "file not found" error even though I am using 'w '. I tried

chmod -R 777 program_directory

to no avail. I am completely new to Linux so I have no idea what to try next.

Thanks a lot!

CodePudding user response:

Oh wow. Linux paths are case sensitive. Sorry about that, I didn't know. Thanks for all the help!

CodePudding user response:

Following are ways to execute python programs in linux:

chmod  x codefile.py #Assigns permission to execute
./codefile.py  #executes

or

python code.py #executes

if you intend to invoke a particular python environment then:

python3 code.py

or

python #activates python session
import code #will import the functions and instructions of code.py
  • Related