6

I just created a vagrant box with ubuntu/trusty32. The vagrant provisioner, during box creation time, has done the following:

  • downloaded python virtualenv source tarball using wget
  • untarred the virtualenv source tarball using tar zxvf ./virtualenv.tar.gz
  • created a virtualenv called venv using python ./virtualenv/virtualenv.py ./venv
  • sourced the newly created venv with source ./venv/bin/activate
  • installed a few pip packages with pip install django, pip install mysqlclient etc inside the virtual environment.

All of this worked fine and perfect - executed by the vagrant provisioner when the vagrant box was being created for the first time.

However, later on, i logged in to the vagrant ssh and tried to install ipython via pip.

$ vagrant ssh vagrant@django-box:~$ source venv/bin/activate (venv) vagrant@django-box:~$ pip install ipython Traceback (most recent call last): File "/home/vagrant/venv/bin/pip", line 11, in <module> sys.exit(main()) File "/home/vagrant/venv/local/lib/python2.7/site-packages/pip/__init__.py", line 215, in main locale.setlocale(locale.LC_ALL, '') File "/home/vagrant/venv/lib/python2.7/locale.py", line 579, in setlocale return _setlocale(category, locale) locale.Error: unsupported locale setting (venv) vagrant@django-box:~$ 

Note: this is a fresh new vagrant box running ubuntu/trusty32 out of the box.

There are several SO questions about locale error but following them revealed no help for this vagrant scenario.

It doesn't make sense that all of it worked perfectly fine during vagrant box creation/provision time but not working afterwards when trying the same thing manually.

1 Answer 1

16

First check your current locale config by simply putting locale in command line.

You should see something similar to:

locale: Cannot set LC_CTYPE to default locale: No such file or directory LANG=C LC_CTYPE=utf8 

Set a valid locale in the LC_CTYPE environment variable by running the following commands:

export LANGUAGE=en_US.UTF-8 export LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8 export LC_CTYPE="en_US.UTF-8" locale-gen en_US.UTF-8 sudo dpkg-reconfigure locales 

PS. en_US.UTF-8 is used here but if you need to check all available locales on your system, run the command locale -a

This should solve the problem.

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

4 Comments

great... this worked... .what just happened??? is there any difference between wrapping en_US.UTF-8 inside quotes and not wrapping en_US.UTF-8 inside quotes?
note.. i am needing to do this every time i am logging into the machine's shell. How do i make it permanent?
You can add the commands in .bashrc and that way it will get executed each time you log into your shell. And also don't forget to mark this as answer so that anyone else having the problem can consider it as answer :)
still don't understand why it worked fine by the vagrant provisioner but not when trying it manually

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.