繁体   English   中英

无法在Python3.4中导入Django

[英]Unable to import Django in Python3.4

我是Ubuntu的新手(14.04)。 我刚刚使用sudo pip install Django

这就是发生的事情:

rpr@rpr-Inspiron-3521:~$ python
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
>>> 

rpr@rpr-Inspiron-3521:~$ python3
Python 3.4.0 (default, Apr 11 2014, 13:05:11) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'django'
>>> 

我该怎么做才能使用Python3.4中的Django?

写吧:

sudo pip3 install Django

但最好像Daniel一样使用virtualenv。

参考

如果您无法运行pip3,请使用以下命令安装它:

sudo apt-get install python3-setuptools
sudo easy_install3 pip 

pip可能是为Python 2而不是Python 3安装的。你可能有一个名为pip3的版本,它以Py3为目标。

但是,使用virtualenv会更好。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM