【发布时间】:2019-12-13 23:08:46
【问题描述】:
我尝试将软件包从 anaconda 安装到 google 的 colab。
但它不起作用。整件事都是巫毒魔法。
以下代码在一个单元格中。
笔记本的单元格:
!wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
!bash Miniconda3-latest-Linux-x86_64.sh -b -f -p /usr/local/
!rm Miniconda3-latest-Linux-x86_64.sh
!conda install -y --prefix /usr/local/ ujson aiohttp tqdm
import sys
os.environ['PYTHONPATH'] = "/usr/local/miniconda3"
os.environ['PATH'] = '/usr/local/miniconda3/bin:' + os.environ['PATH']
sys.path.append('/usr/local/lib/python3.6/site-packages/')
import ujson
结果:
ModuleNotFoundError: No module named 'ujson'
如果我使用“!bash”进入 bash shell,然后运行“bash 的”python,我可以在该 python 中导入 ujson。但是,如果我直接在“notebook”的python中导入ujson,就不行了。
这里的方法似乎不再起作用了
- How to build libraries via conda on colab.research?
- What's the latest conda version compatible with Google Colab 提出以下建议,但现在不起作用:
!wget -c https://repo.anaconda.com/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh
!chmod +x Miniconda3-4.5.4-Linux-x86_64.sh
!bash ./Miniconda3-4.5.4-Linux-x86_64.sh -b -f -p /usr/local
!conda install -q -y --prefix /usr/local ujson
import sys
sys.path.append("/usr/local/conda/lib/python3.6/site-packages/")
print(ujson.dumps({1:2}))
最新的 hack 是什么?
【问题讨论】:
-
你要安装什么包?
-
ujson、aiohttp 和 tqdm
标签: python anaconda conda google-colaboratory miniconda