简体   繁体   English

使用Windows运行在Ubuntu上创建的虚拟环境

[英]Using Windows to run a virtual environment Created on Ubuntu

so i have been developing a website with a backend database. 所以我一直在开发一个带有后端数据库的网站。 The following is my current setup and it is working great: 以下是我当前的设置,并且运行良好:

  • Currently using Ubuntu 16.04 当前使用Ubuntu 16.04
  • I created a virtualenv and downloaded Django and postgreSQL within the virtual environment. 我创建了一个virtualenv并在虚拟环境中下载了Django和postgreSQL。
  • I also downloaded and am using Python 3.5.2 within the virtual environment. 我还下载了虚拟环境中的Python 3.5.2,并正在使用它。

My entire folder structure is on GitHub so that I can edit the code on the go (Again, everything working fine on Ubuntu). 我的整个文件夹结构都在GitHub上,因此我可以随时随地编辑代码(再次,在Ubuntu上一切正常。)

The problem comes when I want to start doing some editing on Windows 10 using Powershell. 当我想开始使用Powershell在Windows 10上进行一些编辑时,就会出现问题。 I am unsure of how to run the 'activate.sh', 'activate.csh', or 'activate.fish' file in order to run the virtual environment and initialize my server using 'python manage.py runserver' so I can start editing my website. 我不确定如何运行“ activate.sh”,“ activate.csh”或“ activate.fish”文件以运行虚拟环境并使用“ python manage.py runserver”初始化服务器,因此我可以启动编辑我的网站。

Has anyone run into the problem and found out how to fix this? 有没有人遇到这个问题,并找到解决方法? Any help on how to get started working on Windows would be great. 任何有关如何开始在Windows上工作的帮助都将非常有用。

If you need any more details id be glad to provide them. 如果您需要更多详细信息,很高兴为您提供。

Thanks! 谢谢!

Assuming that you have created a virtualenv on ubuntu without relocatable option. 假设您在ubuntu上创建了virtualenv且没有可重定位选项。 You will have to firstly create a new virtual environment on Windows because they have differences on OS variations. 首先,您必须在Windows上创建一个新的虚拟环境,因为它们在操作系统版本上存在差异。 So navigate to the directory where you would like to create the new virtual environment on Windows and run the following command:- virtualenv . 因此,导航到要在Windows上创建新虚拟环境的目录,然后运行以下命令:-virtualenv。 (Note the . specifies current directory option) After this there will be three directories created in your directory namely 1) Include 2) Lib 3) Scripts (注意。指定当前目录选项)之后,将在您的目录中创建三个目录,即1)包括2)库3)脚本

As now the activate.bat file is in Scripts you can activate your virtualenv by the following command: Scripts\\activate 现在,activate.bat文件位于脚本中,您可以通过以下命令激活virtualenv:Scripts \\ activate

After the environment is activated you can pip install -r requirements.txt and then run your manage.py script as usual. 激活环境后,您可以pip install -r requirements.txt,然后照常运行您的manage.py脚本。

For further reference you can read:- https://virtualenv.pypa.io/en/stable/userguide/ 有关更多参考,您可以阅读: -https : //virtualenv.pypa.io/en/stable/userguide/

暂无
暂无

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

相关问题 如何访问 1 周前使用 ubuntu 创建的虚拟环境? 我只知道虚拟环境的名称但是idk如何访问| PYTHON - How can I access my virtual environment created 1 week ago using ubuntu? I just know the name of the virtual environment but idk how access| PYTHON 使用 powershell 在 windows 上激活虚拟环境 - activating virtual environment on windows using powershell 在Ubuntu上使用virtualenv为python3设置虚拟环境 - Setting up a virtual environment for python3 using virtualenv on Ubuntu 无法在虚拟环境中运行 django-admin.py startproject,或者根本无法在 Ubuntu 中运行 - Cannot run django-admin.py startproject in virtual environment, or at all, in Ubuntu 在Windows上的fabfile中使用activate_this.py激活python虚拟环境 - Activate a python virtual environment using activate_this.py in a fabfile on Windows 如何在windows中使用cmd重新进入我的虚拟环境 - How to re-enter my virtual environment using cmd in windows 使用脚本从虚拟环境外部运行 DJango 服务器 - Run DJango server from outside of virtual environment by using script 在我的 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? 在 Windows 7 上创建 python 虚拟环境 - creating python virtual environment on windows 7 Windows中的Anaconda虚拟环境django - Anaconda virtual environment django in windows
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM