pip install weasyprint on windows

6k views Asked by At

I get this error when i use pip install WeasyPrint

pip install WeasyPrint
Collecting WeasyPrint
  Using cached WeasyPrint-51-py3-none-any.whl (359 kB)
Collecting Pyphen>=0.9.1
  Using cached Pyphen-0.9.5-py2.py3-none-any.whl (3.0 MB)
Collecting tinycss2>=1.0.0
  Using cached tinycss2-1.0.2-py3-none-any.whl (61 kB)
Collecting cssselect2>=0.1
  Downloading cssselect2-0.3.0-py3-none-any.whl (31 kB)
Collecting cairocffi>=0.9.0
  Using cached cairocffi-1.1.0.tar.gz (68 kB)
    ERROR: Command errored out with exit status 1:
     command: 'd:\myshop\virtual\scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\USER\\AppData\\Local\\Temp\\pip-install-qwm3sa11\\cairocffi\\setup.py'"'"'; __file__='"'"'C:\\Users\\USER\\AppData\\Local\\Temp\\pip-install-qwm3sa11\\cairocffi\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\USER\AppData\Local\Temp\pip-pip-egg-info-tqlmdfuq'
         cwd: C:\Users\USER\AppData\Local\Temp\pip-install-qwm3sa11\cairocffi\
    Complete output (107 lines):
    Traceback (most recent call last):
      File "d:\myshop\virtual\lib\site-packages\setuptools\msvc.py", line 489, in _find_latest_available_vc_ver
        return self.find_available_vc_vers()[-1]
    IndexError: list index out of range

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "d:\myshop\virtual\lib\site-packages\setuptools\sandbox.py", line 154, in save_modules
        yield saved
      File "d:\myshop\virtual\lib\site-packages\setuptools\sandbox.py", line 195, in setup_context
        yield
      File "d:\myshop\virtual\lib\site-packages\setuptools\sandbox.py", line 250, in run_setup
        _execfile(setup_script, ns)
      File "d:\myshop\virtual\lib\site-packages\setuptools\sandbox.py", line 45, in _execfile
        exec(code, globals, locals)
      File "C:\Users\USER\AppData\Local\Temp\easy_install-_u06tvni\cffi-1.14.3\setup.py", line 131, in <module>
      File "C:\Users\USER\AppData\Local\Temp\easy_install-_u06tvni\cffi-1.14.3\setup.py", line 109, in uses_msvc
      File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\distutils\command\config.py", line 225, in try_compile
        self._compile(body, headers, include_dirs, lang)
      File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\distutils\command\config.py", line 132, in _compile
        self.compiler.compile([src], include_dirs=include_dirs)
      File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\distutils\_msvccompiler.py", line 360, in compile
        self.initialize()
      File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\distutils\_msvccompiler.py", line 253, in initialize
        vc_env = _get_vc_env(plat_spec)
      File "d:\myshop\virtual\lib\site-packages\setuptools\msvc.py", line 185, in msvc14_get_vc_env
        return EnvironmentInfo(plat_spec, vc_min_ver=14.0).return_env()
      File "d:\myshop\virtual\lib\site-packages\setuptools\msvc.py", line 843, in __init__
        self.si = SystemInfo(self.ri, vc_ver)
      File "d:\myshop\virtual\lib\site-packages\setuptools\msvc.py", line 485, in __init__
        self.vc_ver = vc_ver or self._find_latest_available_vc_ver()
      File "d:\myshop\virtual\lib\site-packages\setuptools\msvc.py", line 492, in _find_latest_available_vc_ver
        raise distutils.errors.DistutilsPlatformError(err)
    distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\USER\AppData\Local\Temp\pip-install-qwm3sa11\cairocffi\setup.py", line 10, in <module>
        setup(
      File "d:\myshop\virtual\lib\site-packages\setuptools\__init__.py", line 144, in setup
        _install_setup_requires(attrs)
      File "d:\myshop\virtual\lib\site-packages\setuptools\__init__.py", line 139, in _install_setup_requires
        dist.fetch_build_eggs(dist.setup_requires)
      File "d:\myshop\virtual\lib\site-packages\setuptools\dist.py", line 716, in fetch_build_eggs
        resolved_dists = pkg_resources.working_set.resolve(
      File "d:\myshop\virtual\lib\site-packages\pkg_resources\__init__.py", line 780, in resolve
        dist = best[req.key] = env.best_match(
      File "d:\myshop\virtual\lib\site-packages\pkg_resources\__init__.py", line 1065, in best_match
        return self.obtain(req, installer)
      File "d:\myshop\virtual\lib\site-packages\pkg_resources\__init__.py", line 1077, in obtain
        return installer(requirement)
      File "d:\myshop\virtual\lib\site-packages\setuptools\dist.py", line 786, in fetch_build_egg
        return cmd.easy_install(req)
      File "d:\myshop\virtual\lib\site-packages\setuptools\command\easy_install.py", line 679, in easy_install
        return self.install_item(spec, dist.location, tmpdir, deps)
      File "d:\myshop\virtual\lib\site-packages\setuptools\command\easy_install.py", line 705, in install_item
        dists = self.install_eggs(spec, download, tmpdir)
      File "d:\myshop\virtual\lib\site-packages\setuptools\command\easy_install.py", line 890, in install_eggs
        return self.build_and_install(setup_script, setup_base)
      File "d:\myshop\virtual\lib\site-packages\setuptools\command\easy_install.py", line 1158, in build_and_install
        self.run_setup(setup_script, setup_base, args)
      File "d:\myshop\virtual\lib\site-packages\setuptools\command\easy_install.py", line 1144, in run_setup
        run_setup(setup_script, args)
      File "d:\myshop\virtual\lib\site-packages\setuptools\sandbox.py", line 253, in run_setup
        raise
      File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\contextlib.py", line 131, in __exit__
        self.gen.throw(type, value, traceback)
      File "d:\myshop\virtual\lib\site-packages\setuptools\sandbox.py", line 195, in setup_context
        yield
      File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\contextlib.py", line 131, in __exit__
        self.gen.throw(type, value, traceback)
      File "d:\myshop\virtual\lib\site-packages\setuptools\sandbox.py", line 166, in save_modules
        saved_exc.resume()
      File "d:\myshop\virtual\lib\site-packages\setuptools\sandbox.py", line 141, in resume
        six.reraise(type, exc, self._tb)
      File "d:\myshop\virtual\lib\site-packages\setuptools\_vendor\six.py", line 685, in reraise
        raise value.with_traceback(tb)
      File "d:\myshop\virtual\lib\site-packages\setuptools\sandbox.py", line 154, in save_modules
        yield saved
      File "d:\myshop\virtual\lib\site-packages\setuptools\sandbox.py", line 195, in setup_context
        yield
      File "d:\myshop\virtual\lib\site-packages\setuptools\sandbox.py", line 250, in run_setup
        _execfile(setup_script, ns)
      File "d:\myshop\virtual\lib\site-packages\setuptools\sandbox.py", line 45, in _execfile
        exec(code, globals, locals)
      File "C:\Users\USER\AppData\Local\Temp\easy_install-_u06tvni\cffi-1.14.3\setup.py", line 131, in <module>
      File "C:\Users\USER\AppData\Local\Temp\easy_install-_u06tvni\cffi-1.14.3\setup.py", line 109, in uses_msvc
      File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\distutils\command\config.py", line 225, in try_compile
        self._compile(body, headers, include_dirs, lang)
      File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\distutils\command\config.py", line 132, in _compile
        self.compiler.compile([src], include_dirs=include_dirs)
      File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\distutils\_msvccompiler.py", line 360, in compile
        self.initialize()
      File "C:\Users\USER\AppData\Local\Programs\Python\Python38-32\lib\distutils\_msvccompiler.py", line 253, in initialize
        vc_env = _get_vc_env(plat_spec)
      File "d:\myshop\virtual\lib\site-packages\setuptools\msvc.py", line 185, in msvc14_get_vc_env
        return EnvironmentInfo(plat_spec, vc_min_ver=14.0).return_env()
      File "d:\myshop\virtual\lib\site-packages\setuptools\msvc.py", line 843, in __init__
        self.si = SystemInfo(self.ri, vc_ver)
      File "d:\myshop\virtual\lib\site-packages\setuptools\msvc.py", line 485, in __init__
        self.vc_ver = vc_ver or self._find_latest_available_vc_ver()
      File "d:\myshop\virtual\lib\site-packages\setuptools\msvc.py", line 492, in _find_latest_available_vc_ver
        raise distutils.errors.DistutilsPlatformError(err)
    distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Pls any way out?Thanks

2

There are 2 answers

2
Adeyemo Toluwanimi On BEST ANSWER

I went through their documentation

I had to install the latest version of python3.x which i currently have as 3.8.2

upgrade pip and setup tools using python -m pip install --upgrade pip setuptools

Finally installed weasyprint using python -m pip install WeasyPrint Then it successfully installed

Successfully built cairocffi
Installing collected packages: six, webencodings, html5lib, pycparser, cffi, cairocffi, tinycss2, cssselect2, defusedxml, CairoSVG, Pyphen, WeasyPrint
Successfully installed CairoSVG-2.4.2 Pyphen-0.9.5 WeasyPrint-51 cairocffi-1.1.0 cffi-1.14.3 cssselect2-0.3.0 defusedxml-0.6.0 html5lib-1.1 pycparser-2.20 six-1.15.0 tinycss2-1.0.2 webencodings-0.5.1

Visit their documentation for more information. Thanks.

0
A_K On

I had the same issue before I used Anaconda, which does a good job at installing dependencies on Windows.

https://www.anaconda.com/products/individual