Pyramid installation – “UnicodeDecodeError: ‘ascii’ codec can’t decode byte” error fix

Following pyramid framework installation notes I kept getting ‘ascii’ codec can’t decode byte error message. The whole error output looked like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
$ bin/easy_install pyramid
Searching for pyramid
Reading http://pypi.python.org/simple/pyramid/
Reading http://docs.pylonshq.com
Reading http://pylonsproject.org
Reading http://docs.pylonsproject.org
Best match: pyramid 1.4a4
Downloading http://pypi.python.org/packages/source/p/pyramid/pyramid-1.4a4.tar.gz#md5=0a5da1a25791764cdfefb15b2d55656a
Processing pyramid-1.4a4.tar.gz
Writing /tmp/easy_install-hrcuuc/pyramid-1.4a4/setup.cfg
Running pyramid-1.4a4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-hrcuuc/pyramid-1.4a4/egg-dist-tmp-kbuxa9
Traceback (most recent call last):
  File "bin/easy_install", line 9, in <module>
    load_entry_point('distribute==0.6.28', 'console_scripts', 'easy_install')()
  File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/easy_install.py", line 1929, in main
    with_ei_usage(lambda:
  File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/easy_install.py", line 1910, in with_ei_usage
    return f()
  File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/easy_install.py", line 1933, in <lambda>
    distclass=DistributionWithoutHelpCommands, **kw
  File "/usr/lib/python3.3/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib/python3.3/distutils/dist.py", line 917, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python3.3/distutils/dist.py", line 936, in run_command
    cmd_obj.run()
  File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/easy_install.py", line 358, in run
    self.easy_install(spec, not self.no_deps)
  File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/easy_install.py", line 598, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)                                                                                                                    
  File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/easy_install.py", line 628, in install_item                                    
    dists = self.install_eggs(spec, download, tmpdir)                                                                                                                              
  File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/easy_install.py", line 823, in install_eggs                                    
    return self.build_and_install(setup_script, setup_base)                                                                                                                        
  File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/easy_install.py", line 1103, in build_and_install                              
    self.run_setup(setup_script, setup_base, args)                                                                                                                                  
  File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/easy_install.py", line 1089, in run_setup                                      
    run_setup(setup_script, args)                                                                                                                                                  
  File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/sandbox.py", line 31, in run_setup                                                    
    lambda: exec(compile(open(                                                                                                                                                      
  File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/sandbox.py", line 79, in run                                                          
    return func()                                                                                                                                                                  
  File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/sandbox.py", line 34, in <lambda>                                                      
    {'__file__':setup_script, '__name__':'__main__'})                                                                                                                              
  File "setup.py", line 122, in <module>                                                                                                                                            
  File "/usr/lib/python3.3/distutils/core.py", line 148, in setup                                                                                                                  
    dist.run_commands()                                                                                                                                                            
  File "/usr/lib/python3.3/distutils/dist.py", line 917, in run_commands                                                                                                            
    self.run_command(cmd)                                                                                                                                                          
  File "/usr/lib/python3.3/distutils/dist.py", line 936, in run_command
    cmd_obj.run()
  File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/bdist_egg.py", line 172, in run
    self.run_command("egg_info")
  File "/usr/lib/python3.3/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python3.3/distutils/dist.py", line 936, in run_command
    cmd_obj.run()
  File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/egg_info.py", line 179, in run
    self.find_sources()
  File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/egg_info.py", line 254, in find_sources
    mm.run()
  File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/egg_info.py", line 308, in run
    self.add_defaults()
  File "/home/pootzko/env/lib/python3.3/site-packages/distribute-0.6.28-py3.3.egg/setuptools/command/egg_info.py", line 339, in add_defaults
    self.read_manifest()
  File "/usr/lib/python3.3/distutils/command/sdist.py", line 377, in read_manifest
    for line in manifest:
  File "/home/pootzko/env/lib/python3.3/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 7896: ordinal not in range(128)

…aaaaand it kept driving me nuts for a couple of hours until it finally came to me that the problem lied my locale setup and not in python setuptools. Simply typing:

1
export LANG='en_US.UTF-8'

in terminal to change the encoding fixed the problem (keep in mind that this changed the locale temporarily only for the current session).

Hope it saved you some time. Cheers!

One Response to “Pyramid installation – “UnicodeDecodeError: ‘ascii’ codec can’t decode byte” error fix”

  1. Parnell Springmeyer writes:

    This helped me a lot – thank you. I have a Vagrant set up with a Chef recipe auto-installing a list of deps for me and it kept failing on a testcase in a project that had unicode characters in it!!

    Couldn’t figure it out for the life of me till I came across this and it clicked, Ruby wasn’t using the environment’s encoding settings when making the command!

    Thanks :)

Leave a Reply