“python: can't open file 'manage.py':

2019-09-05 13:28发布

问题:

I am trying to run a very simple tmux shell script called "split.sh" which splits the terminal windows.

split.sh:

#!/bin/bash
~/build/tmux-1.5/tmux split-window -h
~/build/tmux-1.5/tmux split-window -v
~/build/tmux-1.5/tmux split-window -h

When I type the command "sh ~/build/tmux-1.5/split.sh", this shell script runs fine, splitting the terminal windows.

However, when I set an aliases,

alias sp='sh ~/build/tmux-1.5/split.sh'

and then run "sp", the terminal gives me a wierd error:

python: can't open file 'manage.py': [Errno 2] No such file

I believe this error with "manage.py" has something to do with Django.. but I have no idea why terminal is looking for manage.py. Why is the terminal giving me this error :(???

Thanks.

回答1:

I faced the same problem. 'manage.py' was in the directory but still was having this issue.

python: can't open file 'manage.py': [Errno 2] No such file or directory

What I did was that mentioned complete path to the project where manage.py was located like this and ran the command successfully! it's because the file was located in a subdirectory. You need to either enter the appropriate subdirectory or add it to the filename as I did below

python C:\Users\myuser\python_projects\myproject\manage.py syncdb

Hopefully that will help you to resolve the issue.