virtualenvwrapper functions unavailable in shell scripts

前端 未结 8 723
夕颜
夕颜 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:06

    add these lines to your .bashrc or .bash_profile

    export WORKON_HOME=~/Envs
    source /usr/local/bin/virtualenvwrapper.sh
    

    and reopen your terminal and try

    0 讨论(0)
  • 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 ...
    
    0 讨论(0)
提交回复
热议问题