Situation:
Currently a (small) python library distribution is installed as part of the install in the python26.zip file. You can remove this zip-file and sublime will also look for its libraries in /lib/python2.6 (or ‘…/python26’ in pre-2211 versions)
The problem is that SublimeClang uses some additional libraries which can easily be installed on the local system.
F.e.: If you install the SublimeClang plugin you get a message like: “The ctypes lib cannot be imported. See github.com/quarnster/SublimeClang”
The url suggests you use pythonbrew to fix the error. It involves linking the /lib/python2.6 to a ‘brewed’ install in ~/.pythonbrew
Instead what I did was link /lib/python2.6 to my system-wide 2.6 install: /usr/lib/python2.6.
This has solved the problems for almost a year now.
However, 2 weeks ago an update for python has triggered a problem importing ‘random’:
Lots of times:
[quote]Traceback (most recent call last):
File “./sublime_plugin.py”, line 62, in reload_plugin
File “./Package Control.py”, line 9, in
import urllib2
File “/home/tys/app/SublimeText2.2211/lib/python2.6/urllib2.py”, line 94, in
import httplib
File “/home/tys/app/SublimeText2.2211/lib/python2.6/httplib.py”, line 78, in
import mimetools
File “/home/tys/app/SublimeText2.2211/lib/python2.6/mimetools.py”, line 6, in
import tempfile
File “/home/tys/app/SublimeText2.2211/lib/python2.6/tempfile.py”, line 34, in
from random import Random as _Random
File “/home/tys/app/SublimeText2.2211/lib/python2.6/random.py”, line 47, in
from os import urandom as _urandom
ImportError: cannot import name urandom
[/quote]
This is a common error and the accepted solution is to re-build your virtual environment. (bugs.launchpad.net/ubuntu/+sour … bug/954595)
However, you cannot rebuild the environment since the interpreter is compiled into sublime_text. I tried making a new virtualenv in the python install dir (using python2.6 offcourse) and I get the same error. Including the above libs in any other python (2.6, 2.7, virtualenv or not) does NOT give me this error.
So my guess is there is a discrepancy between the build in python2.6.2 and my system-wide python2.6.8.
What is the actual problem here? Can a decent virtualenv for sublime (not having the compiled in part) fix the issue? What is the appropriate fix? Currently I’m left with the choice of using the included zip file, disabling various plugins or using the system wide python, disabling the whole of python.
Its weird though that the problem actually arised in the new python2.7 version. Why is popping up in my python2.6 install?
Using: Debian, python2.6 (minimal)+python2.7 packages. Files in /usr/lib/python2.6/lib and /usr/lib/python2.7/lib differ.