如何使用bash命令在Windows 10中创建和激活虚拟环境 [英] How to create and activate virtual environment in windows 10 using bash command
问题描述
我正在尝试在Windows 10中使用bash命令激活我的虚拟环境.我正在使用python 3.5.1. F:\ Python \ Python35 是我的python.exe
所在的位置.我的虚拟环境的名称为myvenv
,而 F:\ Python \ virtualenvironment \ myvenv 是我的虚拟环境所在的位置.我使用以下bash命令
I am trying to activate my virtual environment using bash command in windows 10. I am using python 3.5.1 . F:\Python\Python35 is the location where my python.exe
is located. My virtual environment's name is myvenv
and F:\Python\virtualenvironment\myvenv is the location where my virtual environment is located. I created my virtual environment using following bash command
Nazem Mahmud@DESKTOP-VQR06GL MINGW64 /f/Python/virtualenvironment
$ python -m venv myvenv
但是我现在不能激活它.我用
But i can't activate it now. I used
Nazem Mahmud@DESKTOP-VQR06GL MINGW64 /f/Python/virtualenvironment
$ source myvenv/Scripts/activate
和
Nazem Mahmud@DESKTOP-VQR06GL MINGW64 /f/Python/virtualenvironment/myvenv
$ source Scripts/activate
但是没有任何效果.它给了我类似
的错误
bash: Scripts/activate: No such file or directory
But nothing works. It gives me error like
bash: Scripts/activate: No such file or directory
任何人都可以说我如何使用bash命令激活我的虚拟环境吗?
Can anyone say how can i activate my virtual environment using bash command?
推荐答案
我已经解决了.
首先,我使用以下命令安装virtualenv
:
At first, I install virtualenv
using following command:
Nazem Mahmud@DESKTOP-VQR06GL MINGW64 /f/Python/virtualenvironment
$ pip install virtualenv
然后我使用以下命令创建一个新的虚拟环境:
Then I create a new virtual environment using this command:
Nazem Mahmud@DESKTOP-VQR06GL MINGW64 /f/Python/virtualenvironment
$ py -m virtualenv env
在这里,env
是我的虚拟环境名称.接下来,要激活此虚拟环境,我运行了以下命令:
Here, env
is my virtual environment name. Next, to activate this virtual environment I ran following command:
Nazem Mahmud@DESKTOP-VQR06GL MINGW64 /f/Python/virtualenvironment
$ source env/Scripts/activate
这篇关于如何使用bash命令在Windows 10中创建和激活虚拟环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!