Reputation:
I built a script in Jupiter notebook as a .ipynb file and it works perfectly when I run cells.
However, when I export it as a .py file and try and run it from terminal with
python <path/to/file>
it failed with error code:
(base) USER-MBP-3:~ USER$ python /Users/USER/Local/LiveRun.py
191019051505
...
Fetching new data
python: can't open file 'main.py': [Errno 2] No such file or directory
Traceback (most recent call last):
File "/Users/USER/Local/LiveRun.py", line 298, in <module>
prediction_new = subprocess.check_output(pred, shell=True)
File "/anaconda3/lib/python3.7/subprocess.py", line 395, in check_output
**kwargs).stdout
File "/anaconda3/lib/python3.7/subprocess.py", line 487, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'python main.py 191019051505' returned non-zero exit status 2.
Perhaps there is an issue when I run subprocess in terminal?
Thanks
Upvotes: 0
Views: 817
Reputation: 16
Seems like it's trying to run another script within the same directory named "main.py" and it cannot find it.
Try modifying your script to use the full path to the same directory when trying to call ">python main.py"
Otherwise put all your scripts inside the same directory before running it.
Upvotes: 0