无法在本地安装 Google Colab

Mat*_*teo 7 python windows python-3.x pandas google-colaboratory

我一直在尝试在我的计算机(Windows 操作系统)上安装 google-colab 失败。

我运行“pip install google-colab”时的输出很长,但我收到的一些错误是:

> Building wheel for pandas (setup.py) ... error   ERROR: Command
> errored out with exit status 1:    command:
> 'C:\Users\...\Anaconda3\python.exe' -u -c 'import sys, setuptools,
> tokenize; sys.argv[0] =
> '"'"'C:\\Users\\...\\AppData\\Local\\Temp\\pip-install-ifymdm95\\pandas\\setup.py'"'"';
> __file__='"'"'C:\\Users\\...\\AppData\\Local\\Temp\\pip-install-ifymdm95\\pandas\\setup.py'"'"';f=getattr(tokenize,
> '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"',
> '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))'
> bdist_wheel -d 'C:\Users\...\AppData\Local\Temp\pip-wheel-02i01qsx'
Run Code Online (Sandbox Code Playgroud)

然后经过长时间的错误输出,最后是:

 Rolling back uninstall of pandas
  Moving to c:\users\...\anaconda3\lib\site-packages\pandas-1.2.0.dist-info\
   from C:\Users\...\Anaconda3\Lib\site-packages\~andas-1.2.0.dist-info
  Moving to c:\users\...\anaconda3\lib\site-packages\pandas\
   from C:\Users\...\Anaconda3\Lib\site-packages\~-ndas
ERROR: Command errored out with exit status 1: 'C:\Users\...\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\...\\AppData\\Local\\Temp\\pip-install-ifymdm95\\pandas\\setup.py'"'"'; __file__='"'"'C:\\Users\\...\\AppData\\Local\\Temp\\pip-install-ifymdm95\\pandas\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\...\AppData\Local\Temp\pip-record-67jzzkdh\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\...\Anaconda3\Include\pandas' Check the logs for full command output.
Run Code Online (Sandbox Code Playgroud)

任何提示或帮助将不胜感激。

Gon*_*ica 5

Colab 的 issues repo中,Craig Citro(Google Colab 的软件工程师)指出了以下内容

无法在本地运行 Colab 前端。

但要注意的是,Colaboratory 允许您使用 Jupyter 连接到本地运行时。这允许您在本地硬件上执行代码并访问本地文件系统(它是具有本地运行时的 Colab 前端)。如果这是您的目标,在这里您可以找到实现该目标的方法。

设置说明

为了允许 Colaboratory 连接到本地运行的 Jupyter 服务器,您需要执行以下步骤。

步骤 1:安装 Jupyter 在本地计算机上安装 Jupyter。

第 2 步:安装并启用jupyter_http_over_wsjupyter 扩展(一次性) 该jupyter_http_over_ws扩展由 Colaboratory 团队编写,可在GitHub上获取。

pip install jupyter_http_over_ws
jupyter serverextension enable --py jupyter_http_over_ws
Run Code Online (Sandbox Code Playgroud)

第 3 步:启动服务器并进行身份验证

新的笔记本服务器会正​​常启动,但您需要设置一个标志以显式信任来自 Colaboratory 前端的 WebSocket 连接。

jupyter notebook \
  --NotebookApp.allow_origin='https://colab.research.google.com' \
  --port=8888 \
  --NotebookApp.port_retries=0
Run Code Online (Sandbox Code Playgroud)

服务器启动后,它将打印一条消息,其中包含用于身份验证的初始后端 URL。复制此 URL,因为您需要在下一步中提供此 URL。第 4 步:连接到本地运行时

在 Colaboratory 中,单击“连接”按钮并选择“连接到本地运行时...”。在出现的对话框中输入上一步中的 URL,然后单击“连接”按钮。之后,您现在应该连接到本地运行时。