当我在Visual Studio中运行一个新的(Fresh创建而没有任何修改)Flask Web Project时,它不能编译。我收到错误"没有名为flask"的模块。这对我来说没有任何意义,因为它是一个" Flask"我创建的项目,我没有做任何事情来打破它。微软是否有可能为新的Flask项目提供破碎的模板?我很困惑。
当我尝试添加虚拟环境时,我得到以下日志:
Value cannot be null.
Parameter name: valueInstalling 'pip' package manager.
Downloading setuptools from https://go.microsoft.com/fwlink/?LinkId=317603
Traceback (most recent call last):
File "E:\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.1\pip_downloader.py", line 47, in <module>
setuptools_package, _ = urlretrieve(SETUPTOOLS_SOURCE, 'setuptools.tar.gz')
File "C:\Python27\lib\urllib.py", line 94, in urlretrieve
return _urlopener.retrieve(url, filename, reporthook, data)
File "C:\Python27\lib\urllib.py", line 240, in retrieve
fp = self.open(url, data)
File "C:\Python27\lib\urllib.py", line 208, in open
return getattr(self, name)(url)
File "C:\Python27\lib\urllib.py", line 437, in open_https
h.endheaders(data)
File "C:\Python27\lib\httplib.py", line 991, in endheaders
self._send_output(message_body)
File "C:\Python27\lib\httplib.py", line 844, in _send_output
self.send(msg)
File "C:\Python27\lib\httplib.py", line 806, in send
self.connect()
File "C:\Python27\lib\httplib.py", line 1198, in connect
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
File "C:\Python27\lib\ssl.py", line 392, in wrap_socket
ciphers=ciphers)
File "C:\Python27\lib\ssl.py", line 148, in __init__
self.do_handshake()
File "C:\Python27\lib\ssl.py", line 310, in do_handshake
self._sslobj.do_handshake()
IOError: [Errno socket error] [Errno 8] _ssl.c:510: EOF occurred in violation of protocol
'pip' failed to install. Exit code: 1
C:\Python27\python.exe: No module named pip
答案 0 :(得分:2)
您将需要在管理员模式下使用powershell安装如下所示的烧瓶
PS C:\Python34> pip install flask
Collecting flask
Downloading Flask-0.10.1.tar.gz (544kB)
100% |################################| 544kB 210kB/s
Collecting Werkzeug>=0.7 (from flask)
Downloading Werkzeug-0.10.4-py2.py3-none-any.whl (293kB)
100% |################################| 294kB 28kB/s
Collecting Jinja2>=2.4 (from flask)
Downloading Jinja2-2.7.3.tar.gz (378kB)
100% |################################| 380kB 262kB/s
Collecting itsdangerous>=0.21 (from flask)
Downloading itsdangerous-0.24.tar.gz (46kB)
100% |################################| 49kB 293kB/s
Collecting markupsafe (from Jinja2>=2.4->flask)
Downloading MarkupSafe-0.23.tar.gz
Building wheels for collected packages: flask, Jinja2, itsdangerous, markupsafe
Running setup.py bdist_wheel for flask
Stored in directory: C:\Users\TrustM\AppData\Local\pip\Cache\wheels\d2\db\61\cb9b80526b8f3ba89248ec0a29d6da1bb60136
930fca987
Running setup.py bdist_wheel for Jinja2
Stored in directory: C:\Users\TrustM\AppData\Local\pip\Cache\wheels\b3\c0\62\8908d15b90a7de8bd15e2e6e5f5ba1398c0d99
62a6bf8f5
Running setup.py bdist_wheel for itsdangerous
Stored in directory: C:\Users\TrustM\AppData\Local\pip\Cache\wheels\97\c0\b8\b37c320ff57e15f993ba0ac98013eee778920b
b3ebae3cf
Running setup.py bdist_wheel for markupsafe
Stored in directory: C:\Users\TrustM\AppData\Local\pip\Cache\wheels\94\a7\79\f79a998b64c1281cb99fa9bbd33cfc9b8b5775
8218d17a7
Successfully built flask Jinja2 itsdangerous markupsafe
Installing collected packages: Werkzeug, markupsafe, Jinja2, itsdangerous, flask
Successfully installed Jinja2-2.7.3 Werkzeug-0.10.4 flask-0.10.1 itsdangerous-0.24 markupsafe-0.23
PS C:\Python34> pip install django
Collecting django
Downloading Django-1.8.2-py2.py3-none-any.whl (6.2MB)
100% |################################| 6.2MB 15kB/s
Installing collected packages: django
Successfully installed django-1.8.2
PS C:\Python34>