Running python script from inside virtualenv bin is not working

后端 未结 5 2086
闹比i
闹比i 2020-12-24 06:11

I have a script I want to be available globally. I\'ve started it with the standard hashbang:

#! /usr/bin/env python

And linked it into the

5条回答
  •  天命终不由人
    2020-12-24 06:28

    I faced the same problem and came up with this solution: https://github.com/jabbalaci/wpython. It's a script called "wpython" that calls your program with the local Python interpreter in your venv. Thus instead of "/Users/foo/environments/project/env/bin/python myscript.py" it's enough to write "wpython /path/to/myscript.py". A launcher script could look like this:

    #!/usr/bin/env bash
    
    cd /the/directory/where/myscript.py/is/located
    wpython myscript.py
    

提交回复
热议问题