python - Visual Studio 代码 pylint : Unable to import 'protorpc'

标签 python python-2.7 google-app-engine visual-studio-code protorpc

我正在使用 pylintVisual Studio Code开发 Google App Engine (GAE) Cloud Endpoint API in Python .我无法解决 lint 错误。我不知道是什么导致了这个错误,但猜测一下,pylint找不到 protorpc 库?

enter image description here

Troubleshooting Linting 中的推荐修复是将工作区设置配置为指向完全限定的 python 可执行文件。我已经这样做了,但 lint 错误仍然存​​在。

enter image description here

protorpc 本身安装到:

~/google-cloud-sdk/platform/google_appengine/lib/protorpc-1.0/protorpc

...其中包含无法导入的 remote.py 模块:

__init__.py             generate_python.py      protojson.py            transport.py
definition.py           google_imports.py       protourlencode.py       util.py
descriptor.py           message_types.py        registry.py             webapp
generate.py             messages.py             remote.py               wsgi
generate_proto.py       protobuf.py             static

我已将此路径添加到 $PYTHONPATH (连同 kitchen sink ):

export GOOGLE_CLOUD_SDK=~/google-cloud-sdk
export APPENGINE_PATH=$GOOGLE_CLOUD_SDK/platform/google_appengine

export PYTHONPATH=$PYTHONPATH:$GOOGLE_CLOUD_SDK
export PYTHONPATH=$PYTHONPATH:$GOOGLE_CLOUD_SDK/lib
export PYTHONPATH=$PYTHONPATH:$GOOGLE_CLOUD_SDK/lib/googlecloudsdk
export PYTHONPATH=$PYTHONPATH:$GOOGLE_CLOUD_SDK/lib/googlecloudsdk/api_lib
export PYTHONPATH=$PYTHONPATH:$GOOGLE_CLOUD_SDK/platform/google_appengine/lib
export PYTHONPATH=$PYTHONPATH:$GOOGLE_CLOUD_SDK/platform/google_appengine/lib/protorpc-1.0/protorpc

应用程序在本地运行,并且在部署时也运行,所以这似乎只是一个 lint 错误,但令人沮丧的是我无法解决它。

Using third-party libraries状态:

The Python runtime in the standard environment includes the Python standard library, the App Engine libraries, and a few bundled third-party packages.

因此,我假设“App Engine 库”包括 protorpc,但我不确定。此外,Adding the Cloud Endpoints Frameworks library to the sample API只需要将 google-endpoints 安装到应用的 lib 目录:

pip install -t lib google-endpoints --extra-index-url=https://gapi-pypi.appspot.com/admin/nurpc-dev --ignore-installed

我的意思是,我认为我没有安装任何东西,并且我认为我的(网络)应用程序的 lib 目录中没有任何东西。

最佳答案

更改库路径对我有用。点击 Ctrl + Shift + P 并输入 python interpreter 并选择显示的可用选项之一。一个很熟悉(正如前面提到的一个运行良好的 virtualenv)并且它工作正常。记下您正在使用的 python 版本,2.7 或 3.x 并相应地选择

关于python - Visual Studio 代码 pylint : Unable to import 'protorpc' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43574995/

相关文章:

python - 自定义模型移至 scikit-learn

python - Django allauth 允许的 url

python - OpenERP - 将数据复制到不同表中的新记录 - 费用/采购订单

python - 如何在appengine应用程序中使用来自/usr/local/lib/python2.7/dist-packages的模块

google-app-engine - Google App Engine 自定义域未激活 Google 管理的 SSL

google-app-engine - 谷歌应用引擎 : localhost browser caching?

python - 共享只读数据是否复制到不同的进程以进行多处理?

python - 设置索引列的所有列的每行之间的差异

python - 从字典中获取最大值

python - 如何读取当前QTabWidget选项卡的QTextEdit文本?