A Python script that activates the virtualenv and then runs another Python script?(激活 virtualenv 然后运行另一个 Python 脚本的 Python 脚本?)

本文介绍了激活 virtualenv 然后运行另一个 Python 脚本的 Python 脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows Vista 上,我需要一个启动 activate(以激活 virtualenv)脚本的脚本:

On Windows Vista, I need a script that starts the activate (to activate the virtualenv) script in:

C:UsersAdminDesktopvenvScripts

然后,在虚拟环境中,启动到manage.py runserver文件夹中:

And later, in the virtual environment, starts to the manage.py runserver in the folder:

C:UsersAdminDesktophelloworld

我该怎么办?我应该使用哪些模块?

How should I do? What modules should I use?

推荐答案

您可以激活您的 virtualenv,然后使用 bat 文件启动服务器.将此脚本复制到一个文件中并使用 .bat 扩展名(例如 runserver.bat)保存它

You can activate your virtualenv and then start server using a bat file. Copy this script in to a file and save it with .bat extension (eg. runserver.bat)

@echo off
cmd /k "cd /d C:UsersAdminDesktopvenvScripts & activate & cd /d    C:UsersAdminDesktophelloworld & python manage.py runserver"

然后你可以运行这个bat文件(只需双击)来启动服务器

Then you can just run this bat file (just double click) to start the server

这篇关于激活 virtualenv 然后运行另一个 Python 脚本的 Python 脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!