conda-incubator / condacolab

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

environments #12

Open iurisegtovich opened 3 years ago

iurisegtovich commented 3 years ago

shortcoming mentioned "You can only use the base environment, so do not try to create more environments with conda create."

but i think i am actually able to do so, like this:

%%bash
eval "$(conda shell.bash hook)" # copy conda command to shell
conda create -n env_test_1 python=3.6 #older than the default
conda activate env_test_1
python --version
which python

the output is as follows:

Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: /usr/local/envs/env_test_1

  added / updated specs:
    - python=3.6

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    certifi-2021.5.30          |   py36h5fab9bb_0         141 KB  conda-forge
    ld_impl_linux-64-2.36.1    |       hea4e1c9_1         668 KB  conda-forge
    libgcc-ng-9.3.0            |      h2828fa1_19         7.8 MB  conda-forge
    libgomp-9.3.0              |      h2828fa1_19         376 KB  conda-forge
    libstdcxx-ng-9.3.0         |      h6de172a_19         4.0 MB  conda-forge
    python-3.6.13              |hffdb5ce_0_cpython        38.4 MB  conda-forge
    python_abi-3.6             |          2_cp36m           4 KB  conda-forge
    readline-8.1               |       h46c0cb4_0         295 KB  conda-forge
    setuptools-49.6.0          |   py36h5fab9bb_3         936 KB  conda-forge
    sqlite-3.36.0              |       h9cd32fc_0         1.4 MB  conda-forge
    ------------------------------------------------------------
                                           Total:        54.0 MB

The following NEW packages will be INSTALLED:

  _libgcc_mutex      conda-forge/linux-64::_libgcc_mutex-0.1-conda_forge
  _openmp_mutex      conda-forge/linux-64::_openmp_mutex-4.5-1_gnu
  ca-certificates    conda-forge/linux-64::ca-certificates-2021.5.30-ha878542_0
  certifi            conda-forge/linux-64::certifi-2021.5.30-py36h5fab9bb_0
  ld_impl_linux-64   conda-forge/linux-64::ld_impl_linux-64-2.36.1-hea4e1c9_1
  libffi             conda-forge/linux-64::libffi-3.3-h58526e2_2
  libgcc-ng          conda-forge/linux-64::libgcc-ng-9.3.0-h2828fa1_19
  libgomp            conda-forge/linux-64::libgomp-9.3.0-h2828fa1_19
  libstdcxx-ng       conda-forge/linux-64::libstdcxx-ng-9.3.0-h6de172a_19
  ncurses            conda-forge/linux-64::ncurses-6.2-h58526e2_4
  openssl            conda-forge/linux-64::openssl-1.1.1k-h7f98852_0
  pip                conda-forge/noarch::pip-21.1.3-pyhd8ed1ab_0
  python             conda-forge/linux-64::python-3.6.13-hffdb5ce_0_cpython
  python_abi         conda-forge/linux-64::python_abi-3.6-2_cp36m
  readline           conda-forge/linux-64::readline-8.1-h46c0cb4_0
  setuptools         conda-forge/linux-64::setuptools-49.6.0-py36h5fab9bb_3
  sqlite             conda-forge/linux-64::sqlite-3.36.0-h9cd32fc_0
  tk                 conda-forge/linux-64::tk-8.6.10-h21135ba_1
  wheel              conda-forge/noarch::wheel-0.36.2-pyhd3deb0d_0
  xz                 conda-forge/linux-64::xz-5.2.5-h516909a_1
  zlib               conda-forge/linux-64::zlib-1.2.11-h516909a_1010

Downloading and Extracting Packages
libstdcxx-ng-9.3.0   | 4.0 MB    | ########## | 100% 
python-3.6.13        | 38.4 MB   | ########## | 100% 
sqlite-3.36.0        | 1.4 MB    | ########## | 100% 
ld_impl_linux-64-2.3 | 668 KB    | ########## | 100% 
libgomp-9.3.0        | 376 KB    | ########## | 100% 
readline-8.1         | 295 KB    | ########## | 100% 
setuptools-49.6.0    | 936 KB    | ########## | 100% 
libgcc-ng-9.3.0      | 7.8 MB    | ########## | 100% 
python_abi-3.6       | 4 KB      | ########## | 100% 
certifi-2021.5.30    | 141 KB    | ########## | 100% 
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
#
# To activate this environment, use
#
#     $ conda activate env_test_1
#
# To deactivate an active environment, use
#
#     $ conda deactivate

Python 3.6.13
/usr/local/envs/env_test_1/bin/python

as you can see, in the last line the older python has been called successfully

(my use case is testing compilation and running of hybrid python/c++ packages, not for interactive usage in the notebook kernel)

jaimergp commented 3 years ago

Sure, you can hack your way through using Bash cells, but that disclaimer is addressing the (large) part of the Colab users that rely on the interactive Python kernel.

We can add some clarification in the README if you want!

ColderCoder commented 3 years ago

shell commands in the notebook are executed in a temporary subshell

so the env will always be base per !<command> by default

This is the limitation of IPython, not a shortcoming of this project I suppose