search

Home  >  Q&A  >  body text

python - 《Flask Web》一书中pythpn虚拟环境的作用

我刚开始接触《Flask Web 》,已经创建了一个虚拟环境,出现了相应的文件夹,但是接下去一节内容好像没有提到虚拟环境相关知识。请问虚拟环境应该怎样使用,是要把接下来的代码都保存在虚拟环境和的文件夹里面吗? 怎样在虚拟环境中调出Python的IDLE?

PHP中文网PHP中文网2810 days ago438

reply all(4)I'll reply

  • 阿神

    阿神2017-04-18 10:05:18

    • virutalenv is used to isolate Python and Python installation packages.

    • When using virtualenv, you need to run the command in the command line: env/bin/activate

    • IDLE is a Python IDE, and the Python interpreter used is the system default.

    You can use a convenient editor to edit Python code, such as PyCharm in Windows, etc., and then use virtualenv on the command line to run the code.
    You can also specify a virtualenv in Pycharm to run: http://blog.csdn.net/hy245120...

    reply
    0
  • PHPz

    PHPz2017-04-18 10:05:18

    You must not have read the book carefully. The book clearly explains how to use it:

    Now, there is a subfolder named venv in the flasky folder, which saves a new virtual environment with a private Python interpreter in it. Before using this virtual environment, you need to "activate" it. If
    you use the bash command line (Linux and Mac OS Is:
    $ venvScriptsactivate
    $ source venv/bin/activate
    如果使用微软Windows 系统,激活命令是:
    $ venvScriptsactivate

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 10:05:18

    To be honest, I hate using this virtual environment. It is not a particularly ideal solution. It is recommended not to invest too much time. I have been studying docker recently.

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 10:05:18

    You can also use $ source venv/bin/activate 进入虚拟环境, 之后就像普通方式使用 python, pip 等.
    使用结束后可以使用 $ deactivate to exit the virtual environment.

    reply
    0
  • Cancelreply