-
|
I am currently using pyenv virtualenv and the automatic detection of which python pydefix should use is not working properly for me. I start a discussion as it seems I am not the only struggling with virtualenvs. The issue: it seems that the python executable/environment found by cmake for pydefix to use is not the one I want. I didn't find a way to tell cmake which to use. DiagnosticsWhen configuring with but for some reason once running the actual python code it fails: from pydefix import *
import sys
print(sys.executable)returns a different path that the one detected above. The printed path in this case is the same as returned by I also see that The consequences of that are that the python modules are not found. import numpyreturns a AttemptsI tried a couple things, but to no avail:
from pydefix import *
import sys
print(sys.executable)
print(sys.path)
import subprocess
import sys
subprocess.check_call([sys.executable, "-m", "pip", "install", "numpy"])
import numpy as npinside the pydefix script returns: that is pip says that numpy is already installed, then python doesn't find numpy.
These two raise a cmake warning because they appear to rely on the old |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Note that a Python virtual environment is not necessarily uniquely attached to a Python interpreter, even though I don't know off hand how idefix should learn about virtual environments. In case this is useful: the path to an active python environment is accessed via the Also, instead of import subprocess
import sys
subprocess.check_call([sys.executable, "-m", "pip", "install", "numpy"])you can do import pip
pip.main(["install", "numpy"])but that won't help much here |
Beta Was this translation helpful? Give feedback.
-
|
Random thought: maybe the only solution that doesn't involve renouncing isolation of your Python environments is to containerize your setup (but then I'm not convinced it's worth using pydefix at all). |
Beta Was this translation helpful? Give feedback.
-
|
tested on my side, if you initialise PYTHONPATH to the right location in your environment, then it seems that it picks up the right libraries. e.g.: Still looking for a better answer, but let me know if this works for you. |
Beta Was this translation helpful? Give feedback.
tested on my side, if you initialise PYTHONPATH to the right location in your environment, then it seems that it picks up the right libraries. e.g.:
export PYTHONPATH=$VIRTUAL_ENV/lib/python3.10/site-packagesStill looking for a better answer, but let me know if this works for you.