无法在 Windows 8 上为 Flask 安装 virtualenv
Trouble installing virtualenv on Windows 8 for Flask
我目前正在尝试通过以下方式学习 Flask this tutorial
,但我在需要安装 virtualenv 的第一部分遇到了麻烦。以下是我采取的步骤和结果:
- 编辑我的 PATH 以包含
D:\Program Files\Python3
和 D:\Program Files\Python3\Scripts
- 打开命令提示符(运行它作为管理员)
- 导航到我想在其中创建项目的目录
- 键入
python -m venv flask
并创建了一个包含 flask 的文件夹
- 键入
pip install virtualenv
错误出现的地方是:
Traceback (most recent call last):
File "D:\Program Files\Python3\lib\runpy.py", line 170, in _run_module_as_main "__main__", mod_spec)
File "D:\Program Files\Python3\lib\runpy.py", line 85, in _run_code exec(code, run_globals)
File "D:\Program Files\Python3\Scripts\pip.exe__main__.py", line 5, in
ImportError: No module named 'pip'
我觉得这很奇怪,因为路径是准确的。我什至通过输入 echo %PATH%
确认了这一点并得到了这些结果:
C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:
\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\Syst
em32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Int
el(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Man
agement Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine
Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Component
s\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x
86)\Skype\Phone\;D:\Program Files\Python3;D:\Program Files\Python3\Scripts
我是 运行 Python 3.4.3
正如您通过此屏幕截图所见,我的 PATH 应该是正确的:
想通了:
出于某种原因,如果 Python 安装在不是 C:/ 驱动器的驱动器上,pip install virtualenv
将无法工作。我将 Python 重新安装到 c:/Python34 并再次尝试 pip install virtualenv
(在更改 PATH 之后)并且它工作正常。
我目前正在尝试通过以下方式学习 Flask this tutorial ,但我在需要安装 virtualenv 的第一部分遇到了麻烦。以下是我采取的步骤和结果:
- 编辑我的 PATH 以包含
D:\Program Files\Python3
和D:\Program Files\Python3\Scripts
- 打开命令提示符(运行它作为管理员)
- 导航到我想在其中创建项目的目录
- 键入
python -m venv flask
并创建了一个包含 flask 的文件夹 - 键入
pip install virtualenv
错误出现的地方是:
Traceback (most recent call last):
File "D:\Program Files\Python3\lib\runpy.py", line 170, in _run_module_as_main "__main__", mod_spec)
File "D:\Program Files\Python3\lib\runpy.py", line 85, in _run_code exec(code, run_globals)
File "D:\Program Files\Python3\Scripts\pip.exe__main__.py", line 5, in
ImportError: No module named 'pip'
我觉得这很奇怪,因为路径是准确的。我什至通过输入 echo %PATH%
确认了这一点并得到了这些结果:
C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C: \Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\Syst em32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Int el(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Man agement Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Component s\IPT;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x 86)\Skype\Phone\;D:\Program Files\Python3;D:\Program Files\Python3\Scripts
我是 运行 Python 3.4.3
正如您通过此屏幕截图所见,我的 PATH 应该是正确的:
想通了:
出于某种原因,如果 Python 安装在不是 C:/ 驱动器的驱动器上,pip install virtualenv
将无法工作。我将 Python 重新安装到 c:/Python34 并再次尝试 pip install virtualenv
(在更改 PATH 之后)并且它工作正常。