首页 > 解决方案 > 将代码从 Colab 转移到 Jupyter Notebook

问题描述

我尝试将一些代码从 Colab 转移到 Jupyter 笔记本。

Colab 中的代码是:

# Use some functions from tensorflow_docs
!pip install -q git+https://github.com/tensorflow/docs

我得到错误:

ERROR: Could not detect requirement name for 'git+https://github.com/tensorflow/docs', please specify one with #egg=your_package_name"

另外,如果它尝试不使用“!” 在一开始的时候:

 pip install -q git+https://github.com/tensorflow/docs

我得到一个错误:

File "<ipython-input-11-8fda094c7d6e>", line 5
pip install -q git+https://github.com/tensorflow/docs
          ^
SyntaxError: invalid syntax

有人可以帮我吗?

标签: tensorflowjupyter-notebookgoogle-colaboratory

解决方案


没有 ! 不作为!用于在 Jupyter iPython 环境中调用 bash shell。

我在 Google Cloud Platform Notebook(Jupyter Lab 版本 1.1.4)中尝试了使用 Python 版本(Python 3.5.3)的命令:

!pip3 install -q git+https://github.com/tensorflow/docs --user

并完美地工作。

!pip3 freeze | grep tensorflow
tensorflow==1.15.0
tensorflow-datasets==1.2.0
tensorflow-docs==0.0.0
tensorflow-estimator==1.15.1
tensorflow-hub==0.6.0
tensorflow-io==0.8.0
tensorflow-metadata==0.15.0
tensorflow-probability==0.8.0
tensorflow-serving-api==1.14.0

推荐阅读