virtualenvwrapper functions unavailable in shell scripts

前端 未结 8 784
夕颜
夕颜 2020-12-01 03:44

So, once again, I make a nice python program which makes my life ever the more easier and saves a lot of time. Ofcourse, this involves a virtualenv, made with the mkvi

8条回答
  •  情深已故
    2020-12-01 04:11

    If your Python script requires a particular virtualenv then put/install it in virtualenv's bin directory. If you need access to that script outside of the environment then you could make a symlink.

    main.py from virtualenv's bin:

    #!/path/to/virtualenv/bin/python
    import yourmodule
    
    if __name__=="__main__":
       yourmodule.main()
    

    Symlink in your PATH:

    pymain -> /path/to/virtualenv/bin/main.py
    

    In bin/run-app:

    #!/bin/sh
    # cd into the project directory
    pymain arg1 arg2 ...
    

提交回复
热议问题