condacolab icon indicating copy to clipboard operation
condacolab copied to clipboard

sys.executable not set correctly

Open duerrsimon opened this issue 3 years ago • 2 comments

This is probably an edge case but I'm importing a library that calls a .py file and uses sys.executable to set the python executable to do this this.

After installing condacolab the value of sys.executable is: /usr/bin/python3.real

It should be /usr/local/bin/python so that packages installed via conda can be found.

The dependencies of the program can only be imported with the latter command.

duerrsimon avatar Feb 03 '22 18:02 duerrsimon

I don't think we have much control there after the kernel restart. python3.real is the one we renamed after making /usr/local/bin/python a shell forwarder with the conda activation and other env var changes. sys.executable gets set by the python launcher itself, but it should have inherited the environment changes needed.

Can you post the error and a reproducer notebook?

jaimergp avatar Feb 04 '22 09:02 jaimergp

Here is a reproduction: https://colab.research.google.com/drive/17d2y0mBPanjPB5ZinjFfTSyOdsNpCnoH?usp=sharing

The error is non-trivial (tmp*.csv not found) but is related to the wrong python executable being called, which lets the import openbabel in the file fail but as that error is not caught by the program it tries to read the non-existing file.

duerrsimon avatar Feb 04 '22 12:02 duerrsimon

Hi @duerrsimon, with #31 being merged, I cannot reproduce this anymore, so I guess it's fixed! :D

You can use the pre-release with:

!pip install -q https://github.com/conda-incubator/condacolab/archive/main.tar.gz

And also, use mamba for a speedy dependency install! I condensed all your deps handling in a one-liner like this:

!mamba install rdkit openbabel pdb2pqr acellera::moleculekit=1.0.0 -c conda-forge  > /dev/null

Adapted notebook here

jaimergp avatar Oct 04 '22 12:10 jaimergp