Closed erikcw closed 8 years ago
Can you give more detail? What's the problem? What does virtualenv do that causes a problem?
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?
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.
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.
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.
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
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.
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.
@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.
I use virtualenv with ob-ipython:
activate ~/.virtualenvs/my-virtual-env/bin/activate.bash
And all bin files added to path. (read doc by virtualenv)
Don't need support virtualenv in ob-ipython!
If support virtualenv need in Emacs, its added this packages: https://www.emacswiki.org/emacs/PythonProgrammingInEmacs#toc5.
You do not need to drag all in one package. Look at Ein, it can not be usable, adding new features, but not fix old bugs.
Use https://github.com/proofit404/pyenv-mode and close this ticket.
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...
Maybe related to #135
It would be great to be able to utilize an ipython install from a virtualenv.