Installed packages disappeared in Google Cloud Shell

可紊 提交于 2019-12-19 10:57:11

问题


I've tried to install bunch of python packages in Google Cloud Platform Console. However, the disk space was not enough and installation failed. Interestingly, at some point, the network connection was lost and I should reconnect it.

And then I've checked some packages which had been already installed before I tried to install other bunch of python packages.

Expecting

$ python
Python 2.7.9 (default, Mar  1 2015, 12:57:24) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> 

But numpy was not found. This is the actual result.

$ python 
Python 2.7.9 (default, Mar  1 2015, 12:57:24) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>> 

Is this a known issue? How can I prevent happening it again?


Repro steps

  1. Click "Activate Google Cloud Shell" icon on the top bar
  2. I have two projects and one of the projects is selected.
  3. Install python-numpy package like this :

    Welcome to Cloud Shell! For help, visit https://cloud.google.com/cloud-shell/help.
    $ sudo apt-get install python-numpy
    
  4. Try to import numpy on python prompt --> it is successfully imported.

  5. Close the tab of the browser or just close the shell tab

  6. A few hours later (maybe 2 hours later), reopen the Cloud Shell.

  7. Try to import numpy on python prompt --> "No module named numpy" error.


回答1:


This is a known limitation of Google Cloud Shell - after about an hour of inactivity, any modifications outside of $HOME are lost, including installed packages. See Custom installed software packages and persistence.

Also note this quote regarding Usage limits:

If you do not access Cloud Shell regularly, we may recycle your home disk. You will receive an email notification before we do so and simply starting a session will prevent its removal. Please consider a different solution on Google Cloud Storage for sensitive data you wish to store long term.




回答2:


You mean in Cloud Shell? Cloud Shell connects to a persistent disk and whatever you install on this disk should be saved. If you see otherwise consistently, let us know the repo steps.



来源:https://stackoverflow.com/questions/36784845/installed-packages-disappeared-in-google-cloud-shell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!