1
votes

I tried to setup virtualenv with virtualenvwrapper on CentOS 7 using pip and I get a UnicodeDecode Error.

Exact Steps:

  • Install CentOS7
  • Install pip via get-pip.py
  • sudo pip install virtualenv
  • sudo pip install virtualenvwrapper
  • export WORKON_HOME=$HOME/.virtualenvs
  • source /usr/local/bin/virtualenvwrapper.sh

when I run mkvirtualenv test I get

 New python executable in test/bin/python
 Traceback (most recent call last):
 File "<string>", line 1, in <module>
 UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 11 ordinal not in range(128)
 ERROR: The executable Blog/bin/python is not functioning
 ERROR: It thinks sys.prefix is u'/home/blaw/\xac./virtualenvs' (should be u'/home/blaw/\xac./virtualenvs/Blog')
 ERROR: virtualenv is not compatible with this system or executable

What am I doing wrong?

2
Can you use env to print your environment and look for any none ASCII characters?Klaus D.

2 Answers

1
votes
echo 'export WORKON_HOME=$HOME/.virtualenvs' >> ~/.bashrc

echo 'source /usr/bin/virtualenvwrapper.sh' >> ~/.bashrc

source ~/.bashrc

mkvirtualenv test

That should be OK.

0
votes

i found two strange lines in your steps list:

  • export WORKON_HOME=$HOME/.virtualenvs
  • source /usr/local/bin/virtualenvwrapper.sh

Does that mean that you just executed these commands in your cli?

Actually, what you have to do, is include these two lines in your .bashrc file, as the answer of sxx implies.

So, instead of echoing and append those lines, i edited the .bashrc file with vim (you can also use nano if its easier to you). And manually add it at the end of the file.

I'm not sure if its better, but i added the tilde symbol (~) insted of the $HOME variable:

export WORKON_HOME=~/.virtualenvs
source /usr/bin/virtualenvwrapper.sh

If you read carefully, in centos7 the virtualenvwrapper.sh script, is located in the directory /usr/bin/ and NOT within /usr/local/bin as you wrote.

Once you added those lines, saved your modified .bashrc file, en exit the vim or nano editor, you can create now the .virtualenvs directory, and then source the .bashrc file (kind of restarting your bash cli, with the changes that you just have made):

mkdir ~/.virtualenvs
source ~/.bashrc

If everything is ok, you should see that the virtualenvwrapper will create some scripts within the .virtualenvs directory.

To test if your virtualenvwrapper is working, you can just create a test-environment:

mkvirtualenv test

The command to exit the environment is deactivate. You can remove your test environment with rmvirtualenv test. I hope it helps.