bugWeeChat - Bugs: bug #35320, sys.path is incorrect when running...


bug #35320: sys.path is incorrect when running in a python virtualenv

Submitted by:  Jamie Kirkpatrick <jkp>
Submitted on:  Tue 17 Jan 2012 10:03:04 AM UTC  
Category:  script API plugins Severity:  3 - Normal
Item Group:  other Status:  None
Privacy:  Public Assigned to:  Sebastien Helleu <flashcode>
Originator Name:  Open/Closed:  Open
Release:  0.3.6 IRC nick:  jkp

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Tue 17 Jan 2012 02:06:47 PM UTC, comment #2: 

The main problem it can create is that it will mean stuff installed in the virtualenv only will not be found when you try to import it.   It's simple to prove.

1. Setup a virtualenv
2. Activate that virtualenv
3. Install pybuffer.py in python/autoload
4. Run weechat-curses
5. Create a pybuffer (/pybuffer)
6. Try to import your module.

This will fail because PYTHONPATH is incorrect for the python instance you are running.

You can confirm that you are running the virtualenv'd instance by doing:

import sys
print sys.executable

Actually this points to a wider issue with the Python plugin implementation.  When you build your python extension loader you hard-link it to a specific version of Python but it is not obvious to the user which version of Python that is.  Experienced developers will probably be able to figure these kinds of issues out but its fairly non-intuitive.

Jamie Kirkpatrick <jkp>
Tue 17 Jan 2012 02:00:48 PM UTC, comment #1: 


What kind of problems could that cause? Do you know a way to see the problem, maybe by writing a script?

Or if you know how to fix, a patch would be welcome, if you can write one (and it must be compatible with Python 3.x, since now the devel version supports both Python 2.x and 3.x).

Sebastien Helleu <flashcode>
Project AdministratorIn charge of this item.
Tue 17 Jan 2012 10:03:04 AM UTC, original submission:  

The sys.path variable in a wee-chat python plugin is incorrect: this is because you use "python_path = PySys_GetObject ("path");" to get the original value but this will not take into account the extra directories added by virtualenv.

It would probably be better to use the output from "python -c 'import sys; print sys.path'" to determine the original value because that will take into account virtualenv environmental settings.

Jamie Kirkpatrick <jkp>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by flashcode (Posted a comment)
  • -email is unavailable- added by jkp (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-01-19 flashcode StatusNeed Info => None
        Release3.3-dev => 0.3.6
    2012-01-17 flashcode StatusNone => Need Info
        Assigned toNone => flashcode

    Back to the top

    Powered by Savane 3.7