Closed csfreebird closed 4 years ago
I you are unable to activate virtualenv then see https://emacs.stackexchange.com/questions/24267/using-org-babel-to-enable-virtualenv
I have used something like:
* Some heading
:PROPERTIES:
:header-args:python: :session test-venv :results output
:header-args:sh: :session test-venv
:END:
#+begin_src elisp
(pyvenv-workon "test-venv-z-XQp3ap")
#+end_src
#+RESULTS:
#+begin_src sh
echo $VIRTUAL_ENV
which python
#+end_src
#+RESULTS:
| /home/compro/.virtualenvs/test-venv-z-XQp3ap |
| /home/compro/.virtualenvs/test-venv-z-XQp3ap/bin/python |
#+begin_src python
import requests
#+end_src
#+RESULTS:
: Traceback (most recent call last):
: File "<stdin>", line 1, in <module>
: ModuleNotFoundError: No module named 'requests'
#+begin_src sh :results silent
pipenv install requests
#+end_src
#+begin_src python
import requests
print("Hello")
#+end_src
#+RESULTS:
: Hello
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!
I am using virtualenv python3 in spacemacs.
press C-c C-c to execute the above block, got error message:
If I run the above code in python3 shell, it works.