Skip to content

virtualenv support #53

Closed
Closed

Description

@erikcw

It would be great to be able to utilize an ipython install from a virtualenv.

Activity

  1. gregsexton commented on Mar 23, 2016

    @gregsexton
    Owner

    Can you give more detail? What's the problem? What does virtualenv do that causes a problem?

  2. erikcw commented on Mar 23, 2016

    @erikcw
    Author

    There just doesn't appear to be an obvious way to tell op-ipython to use the ipython installed in a virtualenv. This is necessary if a project is using virtualenv so that all of its installed libraries can be accessed (including the project code base itself).

    Is it possible to tweak the PATH that ob-ipython uses to launch ipython? Perhaps I'm missing something obvious?

  3. reconmaster commented on Mar 24, 2016

    @reconmaster

    I was about to file the same issue. There are two issues I can't work out that would be really make this a true EIN alternative.

    virtualenv support

    It would be fantastic if the RPC ipython session was capable of utilizing the pyenv-workon much like elpy does with it's virtualenv support. After activating the workon env for such a setup, trying to run the ob-ipython code block fails to recognize the virutalenv and only runs the systemwide python installation.

    tramp

    I put this more in the I am probably not understaning what I am doing category. When I pass a remote directory (computational machine directory) to the org-babel source block with :dir /ssh:remote.machine.edu:/research/data/directory, I am able to see the stuff in that remote folder, but then I am unable to use any of that remote machines virutalenv pacakges to do the analysis I'd like to do.

    I know elpy doesn't support tramp because it does a lot of confusing things, but that is why I use the org babel python blocks to execute remote code after I develop the code with the elpy interface in my local virtualenv.

    EIN is able to avoid this virtualenv problem if I configure the notebook server to luanch in the virutalenv and then remotely do the EIN stuff there. However, I am in your camp that org-mode has many advantages over markdown.

    candy and nuts workflow

    What I would like to be able to do with this is first use the pyenv-workon and select the virtualenv I will use for the analysis. Then using the ipython ob-ipython block, use the functionality with ipython within the code block. As org-babel is able to use tramp to use remote directories already, it would be great if virutalenv support could be worked into this (either locally if that is the only place ipytnhon can work with this package or even better in the remote directory with a remote ipython session).

    Please let me know if this isn't clear. Here is a simple example of where things go wrong.

    #+BEGIN_SRC ipython :session analysis :dir /ssh:research.manchine.edu:/home/reconmaster/data/160324_a_lot_of_data_and_results :exports both :file ./analysis.png
      import matplotlib.pyplot as plt
      import numpy as np
      from skimage import io
    
      # custom image analysis package I wrote and installed in the research virtualenv
      import imanal.display as disp
    #+END_SRC
    
    ---------------------------------------------------------------------------
    ImportError                               Traceback (most recent call last)
    <ipython-input-1-d2a456c0f9dc> in <module>()
          3 from skimage import io
          4 
    ----> 5 import imanal.display as disp
          6 
          7 # load files
    
    ImportError: No module named imanal.display
  4. reconmaster commented on Mar 24, 2016

    @reconmaster

    I've noticed the remote issue has been mentioned #39 and #11. If such support could be addressed, the virtualenv problem could be resolved by connecting an ipython server launched in the desired virtualenv.

  5. gregsexton commented on Apr 24, 2016

    @gregsexton
    Owner

    I've never used virtualenv. How does it work? Is pointing ob-ipython at a different python enough? ob-ipython uses the same mechanism to choose a python install that the builtin mode uses:

    (setq python-shell-interpreter "/usr/local/bin/python")

    Does this help?

    I want to split this issue up as you have multiple concerns going on here. Let's talk about how to select a python install here. I'll create a new issue for tramp/remote support.

  6. erikcw commented on May 5, 2016

    @erikcw
    Author

    @gregsexton Yes, think that might work. For example I can launch a virtualenv python interpreter directly from its path like so ~/.virtualenvs/my-virtual-env/bin/ipython and the path will be set correctly. So python-shell-interpreter may do the trick. I'll try to test it later.

  7. joinvim commented on Jul 9, 2016

    @joinvim
  8. gregsexton commented on Jul 9, 2016

    @gregsexton
    Owner

    Yeah, I'm tempted to agree. Support for choosing a python install is already available. Maybe there should be some docs for this though as it seems to come up semi-frequently...

  9. nanounanue commented on Dec 26, 2017

    @nanounanue

    Maybe related to #135

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions