5

I have been using a python virtual environment (virtualenv) successfully for a while. I just upgraded to the new version of Ubuntu, and it has messed up my environment. I was under the impression that a virtualenv was self-contained, but apparently I was wrong. :)

Here's the error:

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)

I was thinking that maybe it had to do with the fact the Ubuntu changed from Python 3.4 to 3.5, so I tried to change the version my environment used with

 virtualenv --python=/usr/bin/python3.5 py3default

but it wouldn't update Python for me.

Note: this looks to be a duplicate, but doesn't have a solution yet.

Community
  • 1
  • 1
Jeremy
  • 1,960
  • 4
  • 21
  • 42
  • Do you have python 2+ in your system? Check with this statement in your terminal "python2 --version". If yes Try to create virtual env with "virtualenv -p /usr/bin/python2.7 " – Dinesh Sunny Apr 24 '16 at 05:03
  • 1
    Why not just rebuild the `virtualenv` with the new native libraries and `python` version? Should be easy with the help of `pip freeze`. – jordanm Apr 24 '16 at 05:13
  • I can't use pip freeze when this virtualenv is active. – Jeremy Apr 26 '16 at 18:37
  • Possible duplicate of [Installing python3 in a python2 virtual environment](http://stackoverflow.com/questions/41390053/installing-python3-in-a-python2-virtual-environment) – e4c5 Jan 06 '17 at 13:50

1 Answers1

0

It is because your python was upgraded into python3 by default, in my case python3.5, so for the solution you have to install the virtualenv from pip3 like this.

pip3 install virtualenv

I face this problem after upgrading my ubuntu 14.04 LTS to 16.04 LTS.

I hope this will help.

Aditya Kresna Permana
  • 11,869
  • 8
  • 42
  • 48