简体   繁体   English

在 Ubuntu 18.04 中找不到 Python google.appengine.api

[英]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我正在尝试使用 conda、gcloud 和 python 在 Ubuntu 18.04 上设置本地主机环境

I followed these steps here : https://cloud.google.com/sdk/docs/quickstart-debian-ubuntu我在这里按照以下步骤操作: https : //cloud.google.com/sdk/docs/quickstart-debian-ubuntu

And I have gcloud command running.我正在运行 gcloud 命令。

Next step to install the appengine Python libraries安装 appengine Python 库的下一步

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.我在 conda 环境中运行所有内容,但仍然收到一条消息,无法找到下面的库。

 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).更新谷歌云 SDK 本身和/或安装/更新 SDK 组件需要跨安装目录的写入权限,因此这些操作需要在与初始 SDK 安装相同的用户 ID 下执行(不一定是 root/sudo)。

Updates performed using gcloud component commands only have the above requirement.使用gcloud component命令执行的更新仅具有上述要求。 In addition updates using your system's package manager require sudo because only the superuser can make system changes using the package manager.此外,使用系统包管理器的更新需要 sudo,因为只有超级用户才能使用包管理器进行系统更改。

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.您的 SDK 是使用 sudo 权限安装的(您引用的配方中的sudo apt-get update && sudo apt-get install google-cloud-sdk ),因此您在安装/更新 SDK 组件时还必须使用 sudo。

You have 2 options:您有 2 个选择:

  1. install the google-cloud-sdk-app-engine-python package.安装google-cloud-sdk-app-engine-python包。 IMHO this has higher chances of success, especially if there were any ubuntu-specific customisations in the SDK.恕我直言,这有更高的成功机会,特别是如果 SDK 中有任何特定于 ubuntu 的定制。 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.它还可以让您保持 ubuntu 包安装“健全”,因为包管理器提供的信息将与 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.但是有一个缺点:您将依赖 ubuntu 软件包升级来升级您的 SDK 和/或其组件,如果您需要快速进行此类升级,这可能会很不方便。

  2. you could perform the SDK components installation/upgrades via gcloud commands.您可以通过gcloud命令执行 SDK 组件安装/升级。 But these would be totally unknown to the ubuntu package management.但是这些对于 ubuntu 包管理来说是完全未知的。 And you might run into trouble if there are ubuntu-specific customisations as they would not be known to the SDK itself.如果存在特定于 ubuntu 的定制,您可能会遇到麻烦,因为 SDK 本身不知道它们。

There is a 3rd option, maybe a bit more tedious, which is what I chose (I'm running opensuse).有第三个选项,也许有点乏味,这是我选择的(我正在运行 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).您可以下载并安装 SDK 的通用 linux 版本,它是独立的,因为它与包管理器没有关系(因此您实际上不需要 sudo,SDK 可以作为普通用户安装)。 You can find various SDK versions here (regular tar.gz archives).您可以 在此处找到各种 SDK 版本(常规tar.gz档案)。

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.我更喜欢第 3 种方法,因为安装包含在一个目录中,因此我可以同时安装多个版本的 SDK,只需操作符号链接即可轻松在它们之间切换。 In this case installing/updating components would apply to whichever SDK installation is the "current" one.在这种情况下,安装/更新组件将适用于“当前”安装的任何 SDK。 I was even able to keep my installations functional across complete OS re-installs (the SDKs were on a separate partition than the OS).我什至能够在完整的操作系统重新安装中保持我的安装正常运行(SDK 位于与操作系统不同的分区上)。

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

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