没有名为 django.core.management 的模块,在 vm 中安装 django 时出错

No module named django.core.management,error while installing django in vm

当我尝试 运行 我的服务器使用:

./manage.py runserver 0.0.0.0:8000

我收到以下错误:

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named django.core.management

浏览解决方案后,我了解到未安装 Django,因此我尝试在 VM 上安装它。

我尝试了以下方法:

pip install django
yum install django
yum install python-django

我还尝试了 运行使用 sudo -s 和 sudo -E 执行这些命令。

我在使用 pip cmd 时得到以下信息:

Downloading/unpacking django
  Cannot fetch index base URL https://pypi.python.org/simple/
  Could not find any downloads that satisfy the requirement django
No distributions at all found for django
Storing complete log in /root/.pip/pip.log

使用 Yum 我得到:

No package python-django available.
Error: Nothing to do
  • 安装新版本 Python。必须为新安装 Pip 版本。 CentOS 6.6 有默认的 Python 2.6 和默认的 pip 无法正常工作。

  • 使用新的 pip 安装 Django。

  • 不要全局安装新版本的Python因为CentOS依赖 Python 2.6 百胜。