简体   繁体   中英

Python google.appengine.api not found in Ubuntu 18.04

I am trying to set up a localhost enviorment using on Ubuntu 18.04 using conda, gcloud and python

I followed these steps here : https://cloud.google.com/sdk/docs/quickstart-debian-ubuntu

And I have gcloud command running.

Next step to install the appengine Python libraries

gcloud components install app-engine-python

But I get a message that I should run this command

   sudo apt-get install google-cloud-sdk-app-engine-python

I running everything from my conda envirorment but I still get a message tha the libraries bellow can not be found.

 from google.appengine.api import users

Any Clue

Updating the google cloud SDK itself and/or installing/updating SDK components requires write permissions across the installation directory, so these operations need to be executed under the same userid as the initial SDK installation (not necessarily root/sudo).

Updates performed using gcloud component commands only have the above requirement. In addition updates using your system's package manager require sudo because only the superuser can make system changes using the package manager.

Your SDK was installed with sudo permissions ( sudo apt-get update && sudo apt-get install google-cloud-sdk in the recipe you referenced), so you have to also use sudo when installing/updating SDK components.

You have 2 options:

  1. install the google-cloud-sdk-app-engine-python package. IMHO this has higher chances of success, especially if there were any ubuntu-specific customisations in the SDK. It also keeps you ubuntu package installation "sane", in the sense the information provided by the package manager would match what's actually installed in the SDK. There is a disadvantage though: you'd be relying on the ubuntu package upgrades to become available to upgrade your SDK and/or its components, which might be inconvenient if you need such upgrades fast.

  2. you could perform the SDK components installation/upgrades via gcloud commands. But these would be totally unknown to the ubuntu package management. And you might run into trouble if there are ubuntu-specific customisations as they would not be known to the SDK itself.

There is a 3rd option, maybe a bit more tedious, which is what I chose (I'm running opensuse). You can download and install the generic linux version of the SDK, which is standalone in the sense that it has no relationship with the package manager (so you don't actually need sudo, the SDK can be installed as a regular user). You can find various SDK versions here (regular tar.gz archives).

I prefer this 3rd approach because the installation is contained to a directory so I can have multiple versions of the SDK installed simultaneously and easily switch between them just by manipulating symlinks. In this case installing/updating components would apply to whichever SDK installation is the "current" one. I was even able to keep my installations functional across complete OS re-installs (the SDKs were on a separate partition than the OS).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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