[英]falied to install flask under virutalenv on windows — [Error 2] The system cannot find the file specified
我在Windows框上使用python 2.7。我可以使用pip install安裝flask,如下所示:
但是,創建了virtualenv之后,嘗試執行相同的操作時出現以下錯誤。
腳本:
$pip install virtualenv
$cd /d d:
$mkdir test
$cd test
$virtualenv flaskEnv
$cd flaskEnv/Scritps/
$activate
$cd ../../
$pip install flask
日志文件如下:
Collecting flask
Using cached Flask-0.11.1-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): click>=2.0 in c:\projects\flask-react\flsk\lib\site-packages (from flask)
Requirement already satisfied (use --upgrade to upgrade): Werkzeug>=0.7 in c:\projects\flask-react\flsk\lib\site-packages (from flask)
Collecting Jinja2>=2.4 (from flask)
Using cached Jinja2-2.8-py2.py3-none-any.whl
Collecting itsdangerous>=0.21 (from flask)
Collecting MarkupSafe (from Jinja2>=2.4->flask)
Using cached MarkupSafe-0.23.tar.gz
Building wheels for collected packages: MarkupSafe
Running setup.py bdist_wheel for MarkupSafe: started
Running setup.py bdist_wheel for MarkupSafe: finished with status 'error'
Complete output from command c:\projects\flask-react\flsk\scripts\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\admini~1\\appdata\\local\\temp\\pip-build-3ep417\\MarkupSafe\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d c:\users\admini~1\appdata\local\temp\tmp8mkr70pip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win32-2.7
creating build\lib.win32-2.7\markupsafe
copying markupsafe\tests.py -> build\lib.win32-2.7\markupsafe
copying markupsafe\_compat.py -> build\lib.win32-2.7\markupsafe
copying markupsafe\_constants.py -> build\lib.win32-2.7\markupsafe
copying markupsafe\_native.py -> build\lib.win32-2.7\markupsafe
copying markupsafe\__init__.py -> build\lib.win32-2.7\markupsafe
running egg_info
writing MarkupSafe.egg-info\PKG-INFO
writing top-level names to MarkupSafe.egg-info\top_level.txt
writing dependency_links to MarkupSafe.egg-info\dependency_links.txt
warning: manifest_maker: standard file '-c' not found
reading manifest file 'MarkupSafe.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'MarkupSafe.egg-info\SOURCES.txt'
copying markupsafe\_speedups.c -> build\lib.win32-2.7\markupsafe
running build_ext
building 'markupsafe._speedups' extension
error: [Error 2] The system cannot find the file specified
----------------------------------------
Running setup.py clean for MarkupSafe
Failed to build MarkupSafe
Installing collected packages: MarkupSafe, Jinja2, itsdangerous, flask
Running setup.py install for MarkupSafe: started
Running setup.py install for MarkupSafe: finished with status 'error'
Complete output from command c:\projects\flask-react\flsk\scripts\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\admini~1\\appdata\\local\\temp\\pip-build-3ep417\\MarkupSafe\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\admini~1\appdata\local\temp\pip-8v3_ep-record\install-record.txt --single-version-externally-managed --compile --install-headers c:\projects\flask-react\flsk\include\site\python2.7\MarkupSafe:
running install
running build
running build_py
creating build
creating build\lib.win32-2.7
creating build\lib.win32-2.7\markupsafe
copying markupsafe\tests.py -> build\lib.win32-2.7\markupsafe
copying markupsafe\_compat.py -> build\lib.win32-2.7\markupsafe
copying markupsafe\_constants.py -> build\lib.win32-2.7\markupsafe
copying markupsafe\_native.py -> build\lib.win32-2.7\markupsafe
copying markupsafe\__init__.py -> build\lib.win32-2.7\markupsafe
running egg_info
writing MarkupSafe.egg-info\PKG-INFO
writing top-level names to MarkupSafe.egg-info\top_level.txt
writing dependency_links to MarkupSafe.egg-info\dependency_links.txt
warning: manifest_maker: standard file '-c' not found
reading manifest file 'MarkupSafe.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'MarkupSafe.egg-info\SOURCES.txt'
copying markupsafe\_speedups.c -> build\lib.win32-2.7\markupsafe
running build_ext
building 'markupsafe._speedups' extension
error: [Error 2] The system cannot find the file specified
錯誤消息對任何人都有意義嗎? 謝謝
此問題似乎與您在virtualenv中安裝的setuptools版本有關。 降級到較舊的版本為我修復了它。
從您的virtualenv:
pip install setuptools==21.2.1
pip install flask
我昨天有這個問題。 我通過下載MarkupSafe 滾輪並使用pip安裝解決了該問題。 問題出在我頭上。 我認為有關編譯器標志的信息可以抑制生成Speedups文件時的錯誤。
1)從上面的鏈接下載車輪。
2)在Windows上,在與滾輪相同的目錄中打開命令窗口。
3)運行“ pip Install”
在沒有C編譯器的系統上,針對Win7破壞了MarkupSafe的setup.py。 (我為VC ++工作保留了一個單獨的VM)我這樣做是為了使其工作:
pip download MarkupSafe
mkdir temp
open MarkupSafe-0.23.tar.gz with 7-zip, extract all to temp
cd temp
edit setup.py line 119 to read: if 0: #not (is_pypy or is_jython):
python setup.py install
我沒有嘗試調試setup.py以使其正常工作。 我只是想嘗試一下Flask,因為它輕巧易學,而且官方文檔說它可以安裝在Windows上。 也許我應該回到Perl ...
與其他海報不同,MarkupSafe的全局pip安裝對我也不起作用。
這些鏈接對問題有其他觀點/見解: https : //github.com/pallets/markupsafe/issues/26 https://github.com/babun/babun/issues/315
好。 我知道了。 我認為我安裝燒瓶的方式沒有任何問題,正如我在問題中已經提到的那樣,我能夠在全局范圍內安裝它(而無需在virtualenv中運行)。 MarkupSafe軟件包具有使用c實現的擴展,並且我的本地計算機上未安裝Windows sdk,因此當ve_build_ext運行時,****總是失敗**
不同的是,如果不是(is_pypy或is_jython),它會發出警告,這是我在全局安裝它時得到的; 但是,在virtualenv下運行時,它會崩潰。 因此,我很確定在virtualenv下運行時hasattr(sys,'pypy_version_info')返回true。
有人知道“ hasattr(sys,'pypy_version_info')”是什么意思嗎?
# fail safe compilation shamelessly stolen from the simplejson
# setup.py file. Original author: Bob Ippolito
is_jython = 'java' in sys.platform
is_pypy = hasattr(sys, 'pypy_version_info')
def run_setup(with_binary):
ext = Extension('markupsafe._speedups', ['markupsafe/_speedups.c'])
ext_modules = [ext] if with_binary else []
def try_building_extension():
try:
run_setup(True)
except BuildFailed:
LINE = '=' * 74
BUILD_EXT_WARNING = 'WARNING: The C extension could not be ' \
'compiled, speedups are not enabled.'
echo(LINE)
echo(BUILD_EXT_WARNING)
echo('Failure information, if any, is above.')
echo('Retrying the build without the C extension now.')
echo()
run_setup(False)
echo(LINE)
echo(BUILD_EXT_WARNING)
echo('Plain-Python installation succeeded.')
echo(LINE)
如果不是(is_pypy或is_jython):try_building_extension()否則:run_setup(False)
我今天遇到了這個問題,根據上面林肯的建議,可以通過從輪文件手動安裝MarkupSafe來解決。 您可以在此處下載適當的文件。 有幾個可用的。 我不知道它們之間的區別是什么,但是什至可以在Windows 10上安裝的唯一一個是MarkupSafe-0.23-cp27-none-win32.whl 。 下載后,我將其復制到使用virtualenv創建的目錄中(不確定是否必要,但這就是我所做的),並使用pip進行安裝:
C:\flask-test\venv>pip install MarkupSafe-0.23-cp27-none-win32.whl
從該目錄。 之后,我回到主目錄並安裝了Flask
C:\flask-test\venv>cd ..
C:\flask-test>pip install Flask
而且效果很好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.