2

我是一个相当缺乏经验的程序员,正在努力将 Conda 安装到Deepnote中。Pip install 不适用于某些软件包。例如,我正在尝试安装 rdkit,这是一个化学信息学软件包,它具有相当复杂的安装说明或通过 Anaconda/mini-conda 发行版管理的简单的 1 行代码。我真的很喜欢 Deepnote 笔记本,我非常感谢这里的任何帮助。

到目前为止,我已经在 Google Colab 上找到了这个用于安装 Conda 的有用代码:https ://github.com/dataprofessor/code/blob/master/python/google_colab_install_conda.ipynb

! wget https://repo.anaconda.com/miniconda/Miniconda3-py37_4.8.2-Linux-x86_64.sh
! chmod +x Miniconda3-py37_4.8.2-Linux-x86_64.sh
! bash ./Miniconda3-py37_4.8.2-Linux-x86_64.sh -b -f -p /usr/local
import sys
sys.path.append('/usr/local/lib/python3.7/site-packages/')

虽然这在 Google Colab 上成功运行,但我不确定它为什么会失败,如下所示在 Deepnote 上:

--2020-12-04 22:58:34--  https://repo.anaconda.com/miniconda/Miniconda3-py37_4.8.2-Linux-x86_64.sh
Resolving repo.anaconda.com (repo.anaconda.com)... 104.16.130.3, 104.16.131.3, 2606:4700::6810:8203, ...
Connecting to repo.anaconda.com (repo.anaconda.com)|104.16.130.3|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 85055499 (81M) [application/x-sh]
Saving to: ‘Miniconda3-py37_4.8.2-Linux-x86_64.sh’

Miniconda3-py37_4.8 100%[===================>]  81.12M   133MB/s    in 0.6s    

2020-12-04 22:58:35 (133 MB/s) - ‘Miniconda3-py37_4.8.2-Linux-x86_64.sh’ saved [85055499/85055499]

PREFIX=/usr/local
./Miniconda3-py37_4.8.2-Linux-x86_64.sh: line 392: /usr/local/conda.exe: Permission denied
chmod: cannot access '/usr/local/conda.exe': No such file or directory
Unpacking payload ...
./Miniconda3-py37_4.8.2-Linux-x86_64.sh: line 404: /usr/local/conda.exe: No such file or directory
./Miniconda3-py37_4.8.2-Linux-x86_64.sh: line 406: /usr/local/conda.exe: No such file or directory

我也想做 conda install -c bioconda gromacs,我找不到解决方法,所以我希望有人能帮我解决这个查询。

提前谢谢了!

PS我在Mac OS上

4

2 回答 2

5

你可以从 Daniel Zvara 那里查看这个笔记本

通过 3 个简单步骤在 Deepnote 中使用 Conda

总共

# 1. Install Conda and make Conda packages available in current environment

!wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
!chmod +x Miniconda3-latest-Linux-x86_64.sh
!sudo bash ./Miniconda3-latest-Linux-x86_64.sh -b -f -p /usr/local

import sys
sys.path.append('/usr/local/lib/python3.7/site-packages/')

# 2. Package installation
# !sudo conda install -y [EXTRA_OPTIONS] package_name

# So for example Keras from conda-forge channel
!sudo conda install -y -c conda-forge keras

# 3. Package usage

import keras
于 2021-01-10T03:08:00.183 回答
0

还在 Deepnote 社区找到了替代解决方案:https ://community.deepnote.com/c/custom-environments/custom-environment-for-installing-conda-packages

可以使用以下 Dockerfile 设置自定义环境(只需填写所需包的占位符)。

FROM gcr.io/deepnote-200602/templates/deepnote
RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
RUN bash ~/miniconda.sh -b -p $HOME/miniconda
ENV PATH $HOME/miniconda/bin:$PATH
RUN conda install python=3.7 ipykernel -y
RUN conda install <insert packages here> -y
RUN python -m ipykernel install --user --name=conda
ENV DEFAULT_KERNEL_NAME "conda"

Deepnote 中的自定义环境是通过侧边栏中的 Environment 选项卡设置的,为您提供 Dockerfile 的选项。复制并粘贴以上内容,然后单击构建并重新启动机器 - 将设置环境允许您使用 conda。

于 2021-01-11T12:01:37.927 回答