Reputation: 533
I'm trying to run a tiny python script (that imports modules) at the start of another, longer, python script. This is part of an attempt to increase the written quality of my code.
I'm trying to run this tiny setup.py script using the following command:
setup_file = ("/home/solebay/My\ Project\ Name/setup.py")
os.system(setup_file)
But I get the following error:
permission denied
However, this is an unprotected folder I have just created and am working in?
It also raises the following style error (twice, naturally):
w605 invalid escape sequence '\ ' [pep8]
Moreover, this is set to become a SyntaxError
.
I'm being denied permission to my own project folder, and also appear to be being forced to breach style guides for a very simple command.
What is the correct way of running this script that won't lead me to produce poorly written code?
Upvotes: 0
Views: 867
Reputation: 1296
A python script is not an executable. If you are going to use os.system
, you need to run the script using the relevant python command. For example,
os.system('python3 ' + setup_file)
To address the warning invalid escape sequence
, you need to escape backslashes like \\
.
Upvotes: 1