简体   繁体   English

安装python库后无法连接到Google Cloud Datalab

[英]Cannot connect to google cloud datalab after installing python library

After installing LightFM library through the second way: 通过第二种方法安装LightFM库后:

    %%bash
    echo "pip install lightfm" >> /content/datalab/.config/startup.sh
    cat /content/datalab/.config/startup.sh

I cannot connect to datalab instance using datalab connect command. 我无法使用datalab connect命令连接到datalab实例。

In the log files I see that datalab each time tries to install LightFM and finally breakimg down with error: 在日志文件中,我看到datalab每次尝试安装LightFM并最终因错误而崩溃:

    Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-_irDy2/lightfm/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-0GIvgP-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-_irDy2/lightfm/

I think the deletion of the instance would not help. 我认为删除实例无济于事。 How can I solve this? 我该如何解决? Thank you 谢谢

Deleting the instance would help, but you don't have to do that. 删除实例会有所帮助,但是您不必这样做。

Fixing this isn't straighforward unfortunately, I've opened an issue for this to be fixed in Datalab here . 不幸的是,解决这个问题并不轻松,我在这里将要解决的问题在Datalab中解决

You can ssh to the VM running Datalab, either by clicking the SSH button from the cloud console, or by running gcloud compute ssh user@vm if you have gcloud installed locally. 您可以通过单击云控制台中的SSH按钮,或运行gcloud compute ssh user@vm如果您在本地安装了gcloud),将gcloud compute ssh user@vm到运行gcloud compute ssh user@vm

Once you're in the machine, you can find the startup.sh script and remove the erroneous line. 进入计算机后,您可以找到startup.sh脚本并删除错误的行。 Assuming you used the default settings when creating the instance, the file should be under /mnt/disks/datalab-pd/content/datalab/.config/ . 假设您在创建实例时使用了默认设置,则该文件应位于/mnt/disks/datalab-pd/content/datalab/.config/下。 If you don't have an editor to use for this, you can install one, or you can just wipe the file (rename it to something else if you want to keep it around). 如果您没有用于此的编辑器,则可以安装一个,也可以擦除文件(如果要保留该文件,可以将其重命名为其他名称)。

It's probably a good idea to make sure the commands you're adding to the startup script are not going to fail by running them first. 最好先运行添加到启动脚本中的命令,以确保它们不会失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM