Installed packages disappeared in Google Cloud She

2019-05-31 14:36发布

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.

2条回答
【Aperson】
2楼-- · 2019-05-31 14:48

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.

查看更多
叛逆
3楼-- · 2019-05-31 15:02

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.

查看更多
登录 后发表回答