markupsafe: Won't install on Windows

Python 3.6 (x86-64) pip == 9.0.1 setuptools == 34.3.2

(no36) D:\Git\project>pip install --force --upgrade markupsafe
Collecting markupsafe
  Using cached MarkupSafe-1.0.tar.gz
Building wheels for collected packages: markupsafe
  Running setup.py bdist_wheel for markupsafe ... error
  Failed building wheel for markupsafe
  Running setup.py clean for markupsafe
Failed to build markupsafe
Installing collected packages: markupsafe
  Found existing installation: markupsafe 1.0
    Uninstalling markupsafe-1.0:
      Successfully uninstalled markupsafe-1.0
  Running setup.py install for markupsafe ... error
  Rolling back uninstall of markupsafe
Exception:
Traceback (most recent call last):
  File "d:\python\no36\lib\site-packages\pip\compat\__init__.py", line 73, in console_to_str
    return s.decode(sys.__stdout__.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 66: invalid continuation byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "d:\python\no36\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "d:\python\no36\lib\site-packages\pip\commands\install.py", line 342, in run
    prefix=options.prefix_path,
  File "d:\python\no36\lib\site-packages\pip\req\req_set.py", line 784, in install
    **kwargs
  File "d:\python\no36\lib\site-packages\pip\req\req_install.py", line 878, in install
    spinner=spinner,
  File "d:\python\no36\lib\site-packages\pip\utils\__init__.py", line 676, in call_subprocess
    line = console_to_str(proc.stdout.readline())
  File "d:\python\no36\lib\site-packages\pip\compat\__init__.py", line 75, in console_to_str
    return s.decode('utf_8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 66: invalid continuation byte

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Actually, the problem seems to come from missing wheel for MarkupSafe on Pypi. Creating it manually solved the issue for me. Here is the workaround (I use git-bash on Windows):

git clone git@github.com:pallets/markupsafe.git /c/tmp/markupsafe
cd /c/tmp/markupsafe
./setup.py bdist_wheel

The result is a valid wheel: /c/tmp/markupsafe/dist/MarkupSafe-1.0-cp36-cp36m-win_amd64.whl. In your other project where you need to use it, simply call

pip install /c/tmp/markupsafe/dist/MarkupSafe-1.0-cp36-cp36m-win_amd64.whl

And you’re done

Here is a simple solution. Since it is a decode error, it can be solved by changing the console’s coding to utf-8. Just run

chcp 65001
pip install markupsafe

and it works.

@OlegBrony It seems that Markupsafe is failed to build and install, but pip thinks it is already installed after the unsuccessful install. Maybe this issue only appears in Virtualenv environment. Please try to uninstall, ‘chcp 65001’, and install it again.

I also meet this question, I found this is just a decode error. In my environment, the console’s coding is ‘gbk’, and this return s.decode(‘utf-8’). so it make error. when I modify the source code to s.decode(‘gbk’). It works.

Traceback (most recent call last):
  File "c:\users\ray\appdata\local\programs\python\python36\lib\site-packages\pip\compat\__init__.py", line 76, in console_to_str
    return s.decode(sys.__stdout__.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 33: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\ray\appdata\local\programs\python\python36\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "c:\users\ray\appdata\local\programs\python\python36\lib\site-packages\pip\commands\install.py", line 342, in run
    prefix=options.prefix_path,
  File "c:\users\ray\appdata\local\programs\python\python36\lib\site-packages\pip\req\req_set.py", line 784, in install
    **kwargs
  File "c:\users\ray\appdata\local\programs\python\python36\lib\site-packages\pip\req\req_install.py", line 878, in install
    spinner=spinner,
  File "c:\users\ray\appdata\local\programs\python\python36\lib\site-packages\pip\utils\__init__.py", line 676, in call_subprocess
    line = console_to_str(proc.stdout.readline())
  File "c:\users\ray\appdata\local\programs\python\python36\lib\site-packages\pip\compat\__init__.py", line 78, in console_to_str
    return s.decode('utf_8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 33: invalid start byte

I had the same error with Python 3.6 on Windows 10 and @alorence’s solution fixed it.

I also saw this error. But I upgraded my pip to 10.0.1 and resolved problem. My pip verson is pip 10.0.1 from python 3.6 I’m using WIndows 10 now.

I used “git bash” for reinstalation markupsafe and it helped me. No one UnicodeDecodeError

In case someone do have my issue:

Traceback (most recent call last):
  File "run.py", line 2, in <module>
    from app import app
  File "G:\Tommy\Programming\Websites\Python_Websites\flaskHW\app\__init__.py", line 1, in <module>
    from flask import Flask
  File "C:\Program Files\Python36\lib\site-packages\flask\__init__.py", line 19, in <module>
    from jinja2 import Markup, escape
  File "C:\Program Files\Python36\lib\site-packages\jinja2\__init__.py", line 33, in <module>
    from jinja2.environment import Environment, Template
  File "C:\Program Files\Python36\lib\site-packages\jinja2\environment.py", line 15, in <module>
    from jinja2 import nodes
  File "C:\Program Files\Python36\lib\site-packages\jinja2\nodes.py", line 19, in <module>
    from jinja2.utils import Markup
  File "C:\Program Files\Python36\lib\site-packages\jinja2\utils.py", line 647, in <module>
    from markupsafe import Markup, escape, soft_unicode
  File "C:\Program Files\Python36\lib\site-packages\markupsafe\__init__.py", line 14, in <module>
    from markupsafe._compat import text_type, string_types, int_types, \
ModuleNotFoundError: No module named 'markupsafe._compat'

@alorence’s solution fixed it all. Kudos to him for fixing an hours long issue.