在没有安装django的情况下运行django项目 [英] Running django project without django installation

查看:62
本文介绍了在没有安装django的情况下运行django项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Linux OS(Ubuntu 12.04)中使用 Django框架(python和mysql DB)开发了一个项目,我想在另一台计算机上的localhost中运行该项目.使用Linux(Ubuntu 12.04)而不在此处安装Django的情况下,是否可以在不安装django的情况下运行django项目.有什么方法可以运行?

I have developed a project with Django framework(python and mysql DB) in Linux OS(Ubuntu 12.04), I want to run this project in localhost in another machine with Linux(Ubuntu 12.04) without installing Django here, is it possible run a django project without django installation. Is there any way to run so?

谢谢.

推荐答案

为了能够使用常规Django,必须安装它,因为您必须能够执行 import django .但是,将Django作为系统级Python软件包安装绝对不是一个好主意.最好总是使用virtualenvs.它们使您可以处理多个项目,其中每个项目可能需要安装不同的程序包,而不同的项目可能需要使用同一程序包的不同版本.除了使用开发之外,virtualenvs对于在远程计算机上安装软件包也非常有用,即使您没有root特权也是如此.

In order to be able to use regular Django, it has to be installed since you have to be able to do import django. However it is never a good idea to install Django as a system-level Python package. It is always best to work with virtualenvs. They allows you to work on multiple projects where each project might require different packages to be installed, and different projects might require to use different version of the same package. In addition to being used development, virtualenvs are very useful to install packages on remote machines even if you do not have root privileged.

您所需要做的就是下载 virtualenv.py ,然后在远程机器:

All you have to do is download virtualenv.py and then do the following on the remote machine:

$ wget https://raw.github.com/pypa/virtualenv/master/virtualenv.py
$ python virtualenv.py venv
$ cd venv
$ source bin/activate
$ pip install django

这将创建一个virtualenv,您可以在其中安装任何Python软件包而无需root特权.此处.

That will create a virtualenv, into which you can install any Python packages without a need for root privileges. More about virtualenv here.

这篇关于在没有安装django的情况下运行django项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆