conda-incubator / condacolab

Install Conda and friends on Google Colab, easily
MIT License
341 stars 49 forks source link

sys.executable not set correctly #21

Closed duerrsimon closed 2 years ago

duerrsimon commented 2 years ago

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.

jaimergp commented 2 years ago

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?

duerrsimon commented 2 years ago

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.

jaimergp commented 2 years ago

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