Creating a virtual environment in Python

Quick version
This tutorial focuses on creating a virtual environment or venv for use with Python. I only intend to provide a brief introduction to venv, mostly providing the code necessary.

To install the venv software enter the following:

pip install virtualenv
Now you can create a venv on your system. To initiate venv within any directory type the following:

python<version> -m venv <virtual-environment-name>

Like so:

python3 -m venv myVenv

To activate the venv enter the following command:

source myVenv/bin/activate

If on Windows type this command instead:

.\myVenv\Scripts\activate

Now you’re all ready to use your venv. Just install software and dependencies as you normally would.

When you are ready to stop using your venv just type the following:

deactivate

And that’s it. You can now use a virtual environment in Python. For more on venv in Python view the documentation here.

原文链接:Creating a virtual environment in Python

© 版权声明
THE END
喜欢就支持一下吧
点赞7 分享
A good idea without action is worth nothing.
如果没有切实执行,再好的点子也是徒劳
评论 抢沙发

请登录后发表评论

    暂无评论内容