How to create and activate virtual environment in windows 10 using bash command

北城以北 提交于 2019-12-10 21:25:48

问题


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 

and

Nazem Mahmud@DESKTOP-VQR06GL MINGW64 /f/Python/virtualenvironment/myvenv 
$ source Scripts/activate

But nothing works. It gives me error like
bash: Scripts/activate: No such file or directory

Can anyone say how can i activate my virtual environment using bash command?


回答1:


I have solved it.

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

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



回答2:


I also had a similar problem but it was because I was in the same directory as my virtual environment. Try navigating back to the root directory (use cd-) of the project and activate your virtual environment.



来源:https://stackoverflow.com/questions/43441472/how-to-create-and-activate-virtual-environment-in-windows-10-using-bash-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!