0

I'm trying to install Flask and I get this error:

 C:\Users\Eirik\myproject>venv\scripts\activate
(venv) C:\Users\Eirik\myproject>pip install flask
Collecting flask
Exception:
Traceback (most recent call last):
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\basecommand.py", line 211, in main
    status = self.run(options, args)
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\commands\install.py", line 305, in run
    wb.build(autobuilding=True)
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\wheel.py", line 705, in build
    self.requirement_set.prepare_files(self.finder)
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\req\req_set.py", line 334, in prepare_files
    functools.partial(self._prepare_file, finder))
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\req\req_set.py", line 321, in _walk_req_to_install
    more_reqs = handler(req_to_install)
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\req\req_set.py", line 461, in _prepare_file
    req_to_install.populate_link(finder, self.upgrade)
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\req\req_install.py", line 250, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\index.py", line 486, in find_requirement
    all_versions = self._find_all_versions(req.name)
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\index.py", line 404, in _find_all_versions
    index_locations = self._get_index_urls_locations(project_name)
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\index.py", line 378, in _get_index_urls_locations
    page = self._get_page(main_index_url)
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\index.py", line 818, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\index.py", line 928, in get_page
    "Cache-Control": "max-age=600",
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\_vendor\requests\sessions.py", line 477, in get
    return self.request('GET', url, **kwargs)
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\download.py", line 373, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\_vendor\requests\sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\_vendor\requests\sessions.py", line 605, in send
    r.content
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\_vendor\requests\models.py", line 750, in content
    self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\_vendor\requests\models.py", line 673, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\_vendor\requests\packages\urllib3\response.py", line 307, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\_vendor\requests\packages\urllib3\response.py", line 243, in read
    data = self._fp.read(amt)
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 54, in read
    self.__callback(self.__buf.getvalue())
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\_vendor\cachecontrol\controller.py", line 244, in cache_response
    self.serializer.dumps(request, response, body=body),
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\download.py", line 276, in set
    return super(SafeFileCache, self).set(*args, **kwargs)
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\_vendor\cachecontrol\caches\file_cache.py", line 99, in set
    with self.lock_class(name) as lock:
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\_vendor\lockfile\mkdirlockfile.py", line 18, in __init__
    LockBase.__init__(self, path, threaded, timeout)
  File "c:\users\eirik\myproject\venv\lib\site-packages\pip\_vendor\lockfile\__init__.py", line 189, in __init__
    hash(self.path)))
  File "c:\users\eirik\myproject\venv\lib\ntpath.py", line 85, in join
    result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 13: ordinal not in range(128)

I suspect the error might be caused by some special char or something like that, but not sure what. I can't find anything that should cause this, tho i'm very inexperienced with this.

Installing Python went fine, then I installed virtualenv (easy_tools or what it's called again) I got everything working, even activating the virtualenv, but when I try to install Flask as mentioned I get this error.

4
  • Which Shell are you using? Commented Oct 29, 2015 at 1:03
  • I've tried using CMD.exe (With and without administrative rights) Same goes for Powershell. If that was what you were asking? Commented Oct 29, 2015 at 1:25
  • have you tried import sys reload(sys) sys.setdefaultencoding('utf8') Commented Oct 29, 2015 at 1:57
  • I have not tried that, is this something I can type in CMD or powershell? Commented Oct 29, 2015 at 13:42

2 Answers 2

1

this is python problem as Python 3 has default UTF-8 encodings while it is not in case of earlier versions....try this to resolve

Search mimetypes.py in your python directory it would be in Lib folder of Python Open it and find the following lines

  try:
  ctype = ctype.encode(default_encoding) # omit in 3.x!
  except UnicodeEncodeError:
  pass                                                                                   and change it to
  try:
  ctype = ctype.encode(default_encoding) # omit in 3.x!
  except UnicodeDecodeError:
  print ctype   

Hope this might have solved the problem...and try to use Python 3

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you - I will try this first thing tomorrow - Sadly I dont think we can use Python 3 - I'm taking a class and we were instructed to use Python 2.7.10! I'll repost tomorrow with an update! Thank you again!
Hello and thank you for the answer! I've searched using find and manually and this code does not exist within my mimetypes.py. I could find something similar like this tho: try: mimetype = mimetype.encode(default_encoding) except UnicodeEncodeError: continue But thats about it. So not really sure what to do now?
write print mimetype instead of continue in UnicodeDecodeError except UnicodeDecodeError: print mimetype change UnicodeEncodeError to UnicodeDecodeError
Thanks for your time reading and trying to help - but I solved it - my answer is right under here :) I just can't accept it as my own answer in 20 hours or something.
0

I found the solution! Because I live in Scandinavia we have some special letters like "æ, ø, å" - This is what was causing the problem. To get "Virtualenv" to work I had to change my username (and my user folder under C:\Users) to something without those letters in them. Then I managed to install Virtualenv.

However, I got the same error when trying to install flask as this post was about: I found out that my computer name was causing the problem. It also contained special letters, but I changed it late last night and forgot to reboot the computer so the changes take effect - after I rebooted now (I always put my computer to sleep from my tablet and wake it up the same way) it works.

So I guess it's 10 hours of google and forum posting for nothing.

Anyway the solution is to not have any special letters in your username or computer name.

Thanks for all the help you guys gave me! Now on to the assignment!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.