简体   繁体   English

如何在windows中使用cmd重新进入我的虚拟环境

[英]How to re-enter my virtual environment using cmd in windows

I have created a virtual environment for django using cmd我已经使用 cmd 为 django 创建了一个虚拟环境

 pip install virtualenvwrapper-win

 mkvirtualenv test

and here I have installed Django using在这里我安装了 Django 使用

 pip install django

But suppose I close my cmd prompt and restart it.但是假设我关闭了 cmd 提示并重新启动它。 What is the command to re-enter in the (test) environment that I have created.重新进入我创建的(测试)环境的命令是什么。

If you are using the package virtualenvwrapper-win , then you can use the options described in this part of the docs :如果您使用的是 package virtualenvwrapper-win ,那么您可以使用文档的这一部分中描述的选项:

workon [<name>]

If <name> is specified, activate the environment named <name> (change the working virtualenv to <name> ).如果指定了<name> ,则激活名为<name>的环境(将工作的 virtualenv 更改为<name> )。 If a project directory has been defined, we will change into it.如果已定义项目目录,我们将更改为该目录。 If no argument is specified, list the available environments.如果未指定参数,请列出可用环境。 One can pass additional option -c after virtualenv name to cd to virtualenv directory if no projectdir is set.如果没有设置 projectdir,可以在 virtualenv 名称之后将附加选项-c传递给 cd 到 virtualenv 目录。

To reactivate the virtual environment: Virtualenvname\Scripts\activate.bat Eg:testing\Scripts\activate.bat This will opens your virtual environment to use.重新激活虚拟环境: Virtualenvname\Scripts\activate.bat 例如:testing\Scripts\activate.bat 这将打开您的虚拟环境以供使用。

To create a virtual environment open command prompt/terminal and navigate to the directory where you want to create your Django project.要创建虚拟环境,请打开命令提示符/终端并导航到要创建 Django 项目的目录。 Let's say we want to create our project at 'user/hp/' then we'll navigate to the 'user/hp/' and then type the command below.假设我们想在“user/hp/”创建我们的项目,然后我们将导航到“user/hp/”,然后键入下面的命令。

Install the virtual environment安装虚拟环境

在此处输入图像描述

Create a virtual environment创建虚拟环境

C:\Users\hp\mkvirtualenv jangoProject

在此处输入图像描述

To activate env type the below command.要激活 env,请键入以下命令。

C:\Users\hp\jangoProject\Scripts\activate

在此处输入图像描述

To deactivate env type the below command要停用 env,请键入以下命令

在此处输入图像描述

To create a new project type below code在代码下方创建一个新的项目类型

C:\User\hp\django-admin startproject learn1 C:\用户\hp\django-admin startproject learn1

在此处输入图像描述

to re entering the same virtual environment created earlier one should firstly change to the directory where virtual environment is created using the CD(directory).要重新进入之前创建的虚拟环境,首先要切换到使用光盘创建虚拟环境的目录(目录)。 and later change in to the project directory and then change to SCRIPTS and at that moment use the command ACTIVATE to activate the virtual environment.然后切换到项目目录,然后切换到 SCRIPTS,此时使用命令 ACTIVATE 激活虚拟环境。

steps:脚步:

  • cd #project name cd #项目名称
  • cd scripts光盘脚本
  • cd..光盘..
  • use command #activate使用命令#activate

follow the above steps to reactivate virtual environment.按照上述步骤重新激活虚拟环境。

To activate previously created environment, just type the following command in your anaconda prompt:要激活先前创建的环境,只需在 anaconda 提示符下键入以下命令:

conda activate 'name_of_the_environment'

Voila.瞧。 You are now on your virtual environment.您现在处于虚拟环境中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 python workon 命令未激活 cmd windows 中的虚拟环境 7 - python workon command doesn't activate the virtual environment in cmd windows 7 使用Windows运行在Ubuntu上创建的虚拟环境 - Using Windows to run a virtual environment Created on Ubuntu 使用 powershell 在 windows 上激活虚拟环境 - activating virtual environment on windows using powershell 如何使用 Python 为 Windows 激活 Django 中的虚拟环境? - How to activate virtual environment in Django for Windows with Python? 自动重新加载页面,而无需再次重新输入URL Django - reload page automatically without needing to RE-enter URL again Django 在我的 windows 命令提示符中创建了一个虚拟环境“测试”,但工作测试在 Visual Studio 代码中不起作用? 怎么修? - Created a virtual environment 'test' in my windows command prompt, but workon test not working in visual studio code? How to fix? 在cmd中创建虚拟环境目录失败 - Failed to create virtual environment directory in cmd 如何使用 Python 激活虚拟环境 - How to activate a virtual environment using Python 如何在激活虚拟环境之前或之后以及在Windows中停用虚拟环境之前或之后配置虚拟环境挂钩 - How to configure virtual environment hooks before or after activating the virtual environment, and before or after deactivating it in Windows 在Windows上的fabfile中使用activate_this.py激活python虚拟环境 - Activate a python virtual environment using activate_this.py in a fabfile on Windows
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM