无法导入 Django
Can't import django
我安装了 python 2.7,然后通过 pip 安装了 django。
C:\WINDOWS\system32>pip install Django
You are using pip version 6.0.8, however version 6.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting Django
Downloading Django-1.8-py2.py3-none-any.whl (6.2MB)
100% |################################| 6.2MB 79kB/s
Installing collected packages: Django
Successfully installed Django-1.8
C:\WINDOWS\system32>
现在当我尝试导入 django 时什么也做不了。
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django
>>>
有什么办法吗?我尝试重新安装 pip,然后突然间什么都不可能了。
C:\Users\cleanup\Downloads>python get-pip.py
Collecting pip
Downloading pip-6.1.1-py2.py3-none-any.whl (1.1MB)
100% |################################| 1.1MB 335kB/s
Installing collected packages: pip
Found existing installation: pip 1.5.4
Uninstalling pip-1.5.4:
Successfully uninstalled pip-1.5.4
Successfully installed pip-1.5.6
C:\Users\cleanup\Downloads>pip list
'pip' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\cleanup\Downloads>python pip list
python: can't open file 'pip': [Errno 2] No such file or directory
C:\Users\cleanup\Downloads>
既然你已经安装Python成功,Django官网上有一篇关于how to install Django on Windows的有用文档。我觉得有一些不错的资源可以参考。
顺便说一句,在 Windows 上,pip 住在 C:\[pythondir]\scipts
。不要忘记将 pip 路径放入您的系统 PATH 或仅使用 bat 脚本:
@C:\[pythondir]/scripts\pip.exe %*
错误提示Python找不到pip.py
。请确保 pip
的目录在搜索路径上。
要做到这一点,您应该转到 "Advanced System Properties" > "Environment Variables" 并将 %PYTHONHOME%\Scripts
添加到 PATH
。如果您没有 PYTHONHOME
,您应该创建变量并将其设置为您的 Python 家。在大多数情况下,它是 C:\Program Files (x86)\Python
.
我安装了 python 2.7,然后通过 pip 安装了 django。
C:\WINDOWS\system32>pip install Django
You are using pip version 6.0.8, however version 6.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting Django
Downloading Django-1.8-py2.py3-none-any.whl (6.2MB)
100% |################################| 6.2MB 79kB/s
Installing collected packages: Django
Successfully installed Django-1.8
C:\WINDOWS\system32>
现在当我尝试导入 django 时什么也做不了。
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django
>>>
有什么办法吗?我尝试重新安装 pip,然后突然间什么都不可能了。
C:\Users\cleanup\Downloads>python get-pip.py
Collecting pip
Downloading pip-6.1.1-py2.py3-none-any.whl (1.1MB)
100% |################################| 1.1MB 335kB/s
Installing collected packages: pip
Found existing installation: pip 1.5.4
Uninstalling pip-1.5.4:
Successfully uninstalled pip-1.5.4
Successfully installed pip-1.5.6
C:\Users\cleanup\Downloads>pip list
'pip' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\cleanup\Downloads>python pip list
python: can't open file 'pip': [Errno 2] No such file or directory
C:\Users\cleanup\Downloads>
既然你已经安装Python成功,Django官网上有一篇关于how to install Django on Windows的有用文档。我觉得有一些不错的资源可以参考。
顺便说一句,在 Windows 上,pip 住在 C:\[pythondir]\scipts
。不要忘记将 pip 路径放入您的系统 PATH 或仅使用 bat 脚本:
@C:\[pythondir]/scripts\pip.exe %*
错误提示Python找不到pip.py
。请确保 pip
的目录在搜索路径上。
要做到这一点,您应该转到 "Advanced System Properties" > "Environment Variables" 并将 %PYTHONHOME%\Scripts
添加到 PATH
。如果您没有 PYTHONHOME
,您应该创建变量并将其设置为您的 Python 家。在大多数情况下,它是 C:\Program Files (x86)\Python
.