1

is it possible to change the python interpreter for pythontex to a python virtual environment such as a conda venv?

My python functions that I call with pythontex for my latex document depend on packages installed in my conda venv.

If I launch pythontex with my conda environment activated I get the error: ModuleNotFoundError: No module named 'pythontex_utils'

1 Answer 1

1

It seems there is a command line argument "--interpreter" for pythontex: Setting conda environment for pythontex in TexStudio

Edit: After some tests my conclusion is that running this results in the same python interpreter with the same pip packages in both the pythontex.py internally as well as in the \begin{pycode} \end{pycode} section in my LaTeX document:

pipenv run pythontex --interpreter python:"C:/Users/[user]/.virtualenvs/[pipenv_virtual_env_name]/Scripts/python.exe" ./[input_name].tex 
1
  • Welcome to TeX.SE! Commented Nov 8, 2021 at 13:08

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.