os.mkdir() permission denied when running python using shell script

This is my python file wish to run:my_python.py

import os
import numpy as np
os.mkdir(<some path>)
example_code = np.empty(1)

This is my script to run this python script: run_python.sh

python ./my_python.py

This is how I run the .sh file:

bash ./run_python.sh

Then, I get this error:

PermissionError: [Errno 13] Permission denied: '<some path>'

But when I try running .sh as sudo: run_python.sh

sudo bash ./run_python.sh

I get this python error:

 import numpy as np
ImportError: No module named numpy

How do I run .py using .sh with the permission to run os.mkdir()?

I want to run: "run_python.sh -> my_python.py -> mkdir()"

2 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like