DEV Community

Discussion on: Dead Simple Python: Virtual Environments and pip

Collapse
 
ravin309 profile image
Ravinder Kumar

Hello Jason,
I found this article very informative and point-to-point coverage on topics.
Though I still have doubts on she-bang. As you said above if we write !#/usr/bin/env as first line in python script we don't need to call it with 'python' command on terminal. So I tried this by writing 'test.py' on Linux but this script is not getting executed without typing 'python' onto the beginning of the terminal command and it gives error : 'test.py' is not a command..
So I didn't understand the use of she-bang properly.
Are there any exceptions to these?

Collapse
 
codemouse92 profile image
Jason C. McDonald

That error has nothing to do with Python at all. Running just...

test.py
Enter fullscreen mode Exit fullscreen mode

...is going to search your system environment paths for an executable file called test.py, and I can practically guarantee your project folder isn't part of that environment path.

Thus, you need to run...

./test.py
Enter fullscreen mode Exit fullscreen mode

The . means "current working directory", and then you build the relative path from there.