[英]How to run Django after Ubuntu 14.04 install
I am brand new to programming, but hopefully someone can help and this makes sense. 我是编程的新手,但希望有人可以提供帮助,这很有意义。
When I run python from the terminal in Ubuntu it runs it from the following path. 当我在Ubuntu的终端上运行python时,它将从以下路径运行它。
/homeX/your_username/python27/bin/python
I used pip to install django which worked successfully, but it installed it to this path. 我用pip安装了django,它成功运行,但是将它安装到了这个路径。
/usr/local/lib/python2.7/dist-packages/Django
Therefore, when I run python in the terminal it can't find the django framework. 因此,当我在终端中运行python时,找不到django框架。 Also, Ubuntu won't allow me to copy anything into the
homeX/
directory so I can't manually add django either. 另外,Ubuntu不允许我将任何内容复制到
homeX/
目录,因此也无法手动添加django。
pip install django
It will install into global and in any directory django-admin.py startproject
to create your Django project. pip install django
它将安装到global以及任何目录django-admin.py startproject
以创建Django项目。
So after installing django you can import django from the python shell 因此,在安装django之后,您可以从python shell导入django
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>>
So as @Filly
suggested use virtualenv
is best for working with django and installing packages 因此,如
@Filly
建议,使用virtualenv
最适合与django一起使用并安装软件包
pip install virtualenv==1.11.6
after installing try below commands 安装后尝试以下命令
virtualenv source/bin/activate
And after you are in virtual environment. 在虚拟环境中。 Here you can install any packages Django or whatever it ll lie in environment only.
在这里,您可以安装任何Django软件包或仅在环境中安装的任何软件包。
Django can work without virtual env in ubuntu Django可以在ubuntu中不使用虚拟环境的情况下工作
install django 安装django
sudo pip install django==1.7
or
Sudo pip install django==1.8
The path of django installation module repo django安装模块仓库的路径
python -c "import sys; sys.path = sys.path[1:]; import django;
print(django.__path__)"
Now goto terminal 现在转到终端
$ python
>>> import django
>>> django.VERSION
Now start a django project 现在开始一个django项目
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.