user2548635 user2548635 - 2 years ago 388
Python Question

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

I have a mac and I am starting to work on django. When I try to make a project on the terminal by writing

python startproject myproject

I get this error

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

While I was looking around for help, one solution suggested to write type to get the location of and use that.

So when I type

python /usr/local/bin/ startproject myproject

my project is created.

Can anyone tell my why I need to do this and why I can't write just Also is there anyway to get around this?

Answer Source

You're confusing two ways of referring to an executable file.

/usr/local/bin is in your path, and is marked as executable, so you can refer to it without the initial python: startproject myproject

When you start with python, that is saying "start Python with the script at this path". So, you need to pass the full path, if the script you're trying to start isn't in your current directory.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download