简体   繁体   English

无法在Windows的virutalenv下安装flask — [错误2]系统找不到指定的文件

[英]falied to install flask under virutalenv on windows — [Error 2] The system cannot find the file specified

I'm using python 2.7 on a windows box.I'm able to install flask using pip install, as you can see below: 我在Windows框上使用python 2.7。我可以使用pip install安装flask,如下所示:

凉 However, after I created a virtualenv, I got below error when trying to do the same thing. 但是,创建了virtualenv之后,尝试执行相同的操作时出现以下错误。

scripts: 脚本:

$pip install virtualenv  
$cd /d d:
$mkdir test
$cd test
$virtualenv  flaskEnv
$cd flaskEnv/Scritps/
$activate
$cd ../../
$pip install flask

log file as below: 日志文件如下:

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

Does the error message mean something to anyone? 错误消息对任何人都有意义吗? thanks 谢谢

This issue seems to be related with the setuptools version installed in your virtualenv. 此问题似乎与您在virtualenv中安装的setuptools版本有关。 Downgrading to an older version fixed it for me. 降级到较旧的版本为我修复了它。

From your virtualenv: 从您的virtualenv:

pip install setuptools==21.2.1
pip install flask

I had this problem yesterday. 我昨天有这个问题。 I resolved it by downloading the MarkupSafe wheel and installing with pip. 我通过下载MarkupSafe 滚轮并使用pip安装解决了该问题。 The problem was way over my head. 问题出在我头上。 Something about compiler flags in order to suppress an error when generating the Speedups file, I think. 我认为有关编译器标志的信息可以抑制生成Speedups文件时的错误。

1) Download the wheel from the link above. 1)从上面的链接下载车轮。

2) On Windows, open a command window in the same directory as the wheel. 2)在Windows上,在与滚轮相同的目录中打开命令窗口。

3) run "pip Install " 3)运行“ pip Install”

The setup.py of MarkupSafe is broken for Win7 on my system where there is no C compiler. 在没有C编译器的系统上,针对Win7破坏了MarkupSafe的setup.py。 (I keep a separate VM for VC++ work) I did this to get it working: (我为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

I did not try to debug setup.py to work correctly. 我没有尝试调试setup.py以使其正常工作。 I just wanted to try out Flask since it's supposed to be lightweight and easy to learn, and the official docs say it installs on Windows. 我只是想尝试一下Flask,因为它轻巧易学,而且官方文档说它可以安装在Windows上。 Maybe I should go back to Perl... 也许我应该回到Perl ...

Unlike the other poster, a global pip install of MarkupSafe didn't work for me either. 与其他海报不同,MarkupSafe的全局pip安装对我也不起作用。

These links have other views/insights on the problem: https://github.com/pallets/markupsafe/issues/26 https://github.com/babun/babun/issues/315 这些链接对问题有其他观点/见解: https : //github.com/pallets/markupsafe/issues/26 https://github.com/babun/babun/issues/315

ok. 好。 I figure it out. 我知道了。 I don't think there is anything wrong in the way I install flask, as I already mentioned in my question, I am able to install it globally (without running within a virtualenv). 我认为我安装烧瓶的方式没有任何问题,正如我在问题中已经提到的那样,我能够在全局范围内安装它(而无需在virtualenv中运行)。 the MarkupSafe package has an extension which is implement using c, and I don't have windows sdk installed on my local machine, so when ve_build_ext runs, **** it always fail ** MarkupSafe软件包具有使用c实现的扩展,并且我的本地计算机上未安装Windows sdk,因此当ve_build_ext运行时,****总是失败**

the difference is if not (is_pypy or is_jython) , it gives a warning, which is what i got when installing it globally; 不同的是,如果不是(is_pypy或is_jython),它会发出警告,这是我在全局安装它时得到的; it crashes, though, when running under a virtualenv. 但是,在virtualenv下运行时,它会崩溃。 So I'm pretty sure that hasattr(sys, 'pypy_version_info') return true when running under a virtualenv. 因此,我很确定在virtualenv下运行时hasattr(sys,'pypy_version_info')返回true。

Does anybody have an idea what "hasattr(sys, 'pypy_version_info')" mean?? 有人知道“ 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)

if not (is_pypy or is_jython): try_building_extension() else: run_setup(False) 如果不是(is_pypy或is_jython):try_building_extension()否则:run_setup(False)

I had this issue today and was able to resolve it by manually installing MarkupSafe from a wheel file, per Lincoln's suggestion above. 我今天遇到了这个问题,根据上面林肯的建议,可以通过从文件手动安装MarkupSafe来解决。 You can download the appropriate file here . 您可以在此处下载适当的文件。 There were several available. 有几个可用的。 I don't know what the difference between all of them is, but the only one that would even install on Windows 10 was the one called MarkupSafe-0.23-cp27-none-win32.whl . 我不知道它们之间的区别是什么,但是什至可以在Windows 10上安装的唯一一个是MarkupSafe-0.23-cp27-none-win32.whl After downloading it, I copied it into the directory I created using virtualenv (not sure if that's necessary but that's what I did) and installed it with pip: 下载后,我将其复制到使用virtualenv创建的目录中(不确定是否必要,但这就是我所做的),并使用pip进行安装:

C:\flask-test\venv>pip install MarkupSafe-0.23-cp27-none-win32.whl

from that directory. 从该目录。 After that I went back to the main directory and installed Flask 之后,我回到主目录并安装了Flask

C:\flask-test\venv>cd ..
C:\flask-test>pip install Flask

and it worked fine. 而且效果很好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 系统找不到Windows指定的文件错误python - The system cannot find the file specified windows error python Windows 11卸载Python 3.9,安装3.11.1:启动器中出现致命错误:无法使用..创建进程系统找不到指定的文件 - Windows 11 uninstall Python 3.9, install 3.11.1: Fatal error in launcher: Unable to create process using .. The system cannot find the file specified Spyder中的“系统找不到指定的文件”错误 - “The system cannot find the file specified” error in Spyder Biopython错误-系统找不到指定的文件 - Biopython error - The system cannot find the file specified WindowsError:[错误2]系统找不到指定的文件 - WindowsError:[Error 2] The system cannot find the file specified pip install --user numpy,错误:[错误2]系统找不到指定的文件 - pip install --user numpy , error: [Error 2] The system cannot find the file specified WindowsError:[错误2]系统找不到指定的文件 - WindowsError: [Error 2] The system cannot find the file specified 使用 pip 安装 lanms 时出现此错误 FileNotFoundError: [WinError 2] 系统找不到指定的文件 - when using pip install lanms getting this error FileNotFoundError: [WinError 2] The system cannot find the file specified Flask系统找不到指定的路径:“ 130.127.5.9” - Flask The system cannot find the path specified: '130.127.5.9' python easy_install pylint错误:系统找不到指定的文件 - python easy_install pylint Error: The system cannot find the file specified
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM