Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

cool However, after I created a virtualenv, I got below error when trying to do the same thing.

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

like image 224
Bo Chen Avatar asked Jul 07 '16 10:07

Bo Chen


4 Answers

This issue seems to be related with the setuptools version installed in your virtualenv. Downgrading to an older version fixed it for me.

From your virtualenv:

pip install setuptools==21.2.1
pip install flask
like image 187
maxag Avatar answered Oct 25 '22 11:10

maxag


I had this problem yesterday. I resolved it by downloading the MarkupSafe wheel and installing with 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.

1) Download the wheel from the link above.

2) On Windows, open a command window in the same directory as the wheel.

3) run "pip Install "

like image 23
Lincoln Lorscheider Avatar answered Oct 25 '22 09:10

Lincoln Lorscheider


The setup.py of MarkupSafe is broken for Win7 on my system where there is no C compiler. (I keep a separate VM for VC++ work) I did this to get it working:

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. 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. Maybe I should go back to Perl...

Unlike the other poster, a global pip install of MarkupSafe didn't work for me either.

These links have other views/insights on the problem: https://github.com/pallets/markupsafe/issues/26 https://github.com/babun/babun/issues/315

like image 21
rbl Avatar answered Oct 25 '22 09:10

rbl


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). 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 **

the difference is if not (is_pypy or is_jython) , it gives a warning, which is what i got when installing it globally; it crashes, though, when running under a virtualenv. So I'm pretty sure that hasattr(sys, 'pypy_version_info') return true when running under a virtualenv.

Does anybody have an idea what "hasattr(sys, 'pypy_version_info')" mean??

# 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)

like image 20
Bo Chen Avatar answered Oct 25 '22 10:10

Bo Chen