Skip to main content

Restore PYTHONPATH after setup.py install with PYTHONPATH

I ran this command on Ubuntu 14.04 Linux while trying to install a package:

export PYTHONPATH=/usr/local/lib/python2.7/ && sudo python setup.py install

How do I revert this to the stage before running this command-line? Even starting from a fresh bash terminal, it now won't find any of my other python libraries.

Related question wasn't answered: Fixing a broken PYTHONPATH environment variable

[EDIT]

I don't know how to revert to the list of folders before, but I presume it was a combination of /usr/lib/python2.7 and /usr/local/lib/python2.7

Trying virtualenv also fails now:

virtualenv
Fatal Python error: Py_Initialize: Unable to get the locale encoding
  File "/usr/lib/python2.7/encodings/__init__.py", line 123
    raise CodecRegistryError,\
                            ^
SyntaxError: invalid syntax
Aborted (core dumped)

I have now gone through the folder and tried both pip install and apt-get install python-${package} with this:

ls /usr/local/lib/python2.7/dist-packages/*/ | grep -v egg | grep '\:' | tr ':' ' ' | grep -v dist-info | xargs -n1 basename  | while read i; do sudo pip install $i; done

Also:

ls /usr/local/lib/python2.7/dist-packages/*/ | grep -v egg | grep '\:' | tr ':' ' ' | grep -v dist-info | xargs -n1 basename  | while read i; do sudo apt-get install -y python-${i}; done

But still same issues.

I seem to be stuck at this point, not knowing how to proceed any further.

719016
  • 721
  • 3
  • 17
  • 31