Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have upgraded from Ubuntu 12.10 to 13.10. In the meanwhile I have removed the Enthought Python distribution manually because I want to start back on the 'official' packages. So I removed the python folder and redirected the pythonpath towards the official package. Here a dump of PYTHONPATH:

    $ echo $PYTHONPATH
    /usr/local/Madagascar_1.5/lib/python2.7/dist-packages:/usr/lib/python2.7:/usr/local/lib/python2.7:/usr/local/Madagascar_1.5/lib/python2.7:/usr/local/Madagascar_1.5/lib/python2.7/dist-packages:/usr/local/Madagascar_1.5/lib:/usr/lib/python3

Which is theoretically what you need to get everything working. I code with python 2.7 and everything works perfectly.

However to start gedit I need to export

PYTHONPATH=/usr/lib/python3 

whereas it is already in pythonpath. As Gedit depends on python 3 now. I followed this solution but to me it is not satisfactory:

multiple versions of python

When I update my packages with aptitude, I get an error message that gedit has inconsistencies. So the general advice is to reinstall gedit. Here the output:

 sudo apt-get --reinstall install gedit

 Reading package lists... Done
 Building dependency tree       
 Reading state information... Done
 0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 3 not upgraded.
 1 not fully installed or removed.
 Need to get 0 B/492 kB of archives.
 After this operation, 0 B of additional disk space will be used.
 (Reading database ... 304259 files and directories currently installed.)
 Preparing to replace gedit 3.8.3-0ubuntu3 (using      .../gedit_3.8.3-0ubuntu3_amd64.deb) ...
 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)
 dpkg: warning: subprocess old pre-removal script returned error exit status 134
 dpkg: trying script from the new package instead ...
 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)
 dpkg: error processing /var/cache/apt/archives/gedit_3.8.3-0ubuntu3_amd64.deb (--unpack):
  subprocess new pre-removal script returned error exit status 134
 No apport report written because MaxReports is reached already
                                                          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)
 dpkg: error while cleaning up:
  subprocess installed post-installation script returned error exit status 134
 Errors were encountered while processing:
  /var/cache/apt/archives/gedit_3.8.3-0ubuntu3_amd64.deb
 E: Sub-process /usr/bin/dpkg returned an error code (1)

I was wondering if it was my PYTHONHOME which was not properly defined but it did not bring me anywhere to export a variable.

Now the other annoyance is that Ubuntu-desktop being dependant of gedit, it is also broken after an update I made (without thinking...). So now I have no more desktop. Screen is black after logging.

Any suggestion to put gedit back on track?

Thanks in advance

share|improve this question
1  
Those SyntaxErrors are on lines with Python 2 code, not compatible with Python 3. So I guess the Python plugin loader of Gedit only supports Python 3 code. –  Timo Feb 26 at 11:46
    
Yes that is why I am trying to make gedit use Python3. And also it is why I don't understand this behavior when trying to reinstall. –  Boorhin Feb 26 at 14:25

1 Answer 1

Correct me if I'm wrong but aren't you saying that gedit will not work when your PYTHONPATH looks like this:

/usr/local/Madagascar_1.5/lib/python2.7/dist-packages:/usr/lib/python2.7:/usr/local/lib/python2.7:/usr/local/Madagascar_1.5/lib/python2.7:/usr/local/Madagascar_1.5/lib/python2.7/dist-packages:/usr/local/Madagascar_1.5/lib:/usr/lib/python3

But when you manually change it with export to

/usr/lib/python3

It works fine?

Is there any reason why you would want the path to look like in the first example all the time? You could make it to that by adding the export command to ~/bash.rc

edit: Also, could you experiment and try putting the part that gedit likes, /usr/lib/python3, at the start of the path and then the rest of it afterwards, rather than having python3 right at the end? Maybe it uses "short circuit logic" and chooses the first one it finds that works.

share|improve this answer
    
PYTHONPATH is set from /etc/environment because I want it on the whole machine. It is supposedly to be just for the modules, I really don't get it. Especially that now the machine is without ubuntu-desktop... I am about to reinstall 13.10. I will edit this comment if your trick works. –  Boorhin Feb 26 at 10:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.