Created
          March 30, 2018 16:38 
        
      - 
      
- 
        Save stanchan/7e44ae5ae90f11a2a484340e9ffa8154 to your computer and use it in GitHub Desktop. 
    Fix IPython for VIRTUAL_ENV
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import os | |
| import sys | |
| from warnings import warn | |
| virtualenv = os.environ.get('VIRTUAL_ENV') | |
| if virtualenv: | |
| version = os.listdir(os.path.join(virtualenv, 'lib'))[0] | |
| site_packages = os.path.join(virtualenv, 'lib', version, 'site-packages') | |
| lib_dynload = os.path.join(virtualenv, 'lib', version, 'lib-dynload') | |
| if not (os.path.exists(site_packages) and os.path.exists(lib_dynload)): | |
| msg = 'Virtualenv site-packages discovery went wrong for %r' % repr([site_packages, lib_dynload]) | |
| warn(msg) | |
| sys.path.insert(0, site_packages) | |
| sys.path.insert(1, lib_dynload) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment