pythonvirtualenvpython-idle

How to launch python Idle from a virtual environment (virtualenv)


I have a package that I installed from a virtual environment. If I just launch the python interpreter, that package can be imported just fine. However, if I launch Idle, that package cannot be imported (since it's only available in one particular virtualenv and not global). How can I launch Idle from a virtualenv, so that all packages from the virtualenv would be available?


Solution

  • For Python 3.6+, please see Paul Wicking's answer below.

    In Python prior to 3.6, IDLE is essentially

    from idlelib.PyShell import main
    if __name__ == '__main__':
      main()
    

    So you can launch it yourself unless you built the virtualenv without default packages.