search

Home  >  Q&A  >  body text

大家好,请问在python脚本中怎么用virtualenv激活指定的环境?

我是想在py脚本执行时,激活指定的环境。可以做到吗?

PS:我是李世石,我已经弃围棋从AI了,大家多指教!

伊谢尔伦伊谢尔伦2820 days ago982

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-04-18 10:26:27

    sys.path.insert Your environment directory. For example:

    sys.path.insert(0, "/tmp/python2.7.8/lib/python2.7/site-packages/")

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 10:26:27

    Yes, you need to use the absolute path to specify the python you use (in the virtual environment). The rough writing method is as follows

    /PATH/venv/bin/python /PATH/script.py

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 10:26:27

    Spend half an hour and read through the documentation of virtualenvwrapper, and all the problems will be solved

    reply
    0
  • Cancelreply