无法在Python3.4中导入Django

2024-05-22 02:01:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我是新来的Ubuntu(14.04)。我刚刚用sudo pip install Django安装了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?


Tags: ordjangodefaultforlicenseonmoretype
2条回答

写下:

sudo pip3 install Django

但最好像丹尼尔说的那样使用virtualenv。

Reference

如果无法使用following运行pip3,请安装它:

sudo apt-get install python3-setuptools
sudo easy_install3 pip 

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

不过,最好使用virtualenv。

相关问题 更多 >