Os. Mkdir() Permission Denied When Running Python Using Shell Script

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
Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.