Visual Studio Code pylint:无法导入“protorpc" [英] Visual Studio Code pylint: Unable to import 'protorpc'

查看:26
本文介绍了Visual Studio Code pylint:无法导入“protorpc"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在

protorpc 本身安装到:

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

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

__init__.py generate_python.py protojson.py transport.py定义.py google_imports.py protourlencode.py util.pydescriptor.py message_types.py registry.py webappgenerate.py messages.py remote.py wsgigenerate_proto.py protobuf.py 静态

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

导出 GOOGLE_CLOUD_SDK=~/google-cloud-sdk导出 APPENGINE_PATH=$GOOGLE_CLOUD_SDK/platform/google_appengine导出 PYTHONPATH=$PYTHONPATH:$GOOGLE_CLOUD_SDK导出 PYTHONPATH=$PYTHONPATH:$GOOGLE_CLOUD_SDK/lib导出 PYTHONPATH=$PYTHONPATH:$GOOGLE_CLOUD_SDK/lib/googlecloudsdk导出 PYTHONPATH=$PYTHONPATH:$GOOGLE_CLOUD_SDK/lib/googlecloudsdk/api_lib导出 PYTHONPATH=$PYTHONPATH:$GOOGLE_CLOUD_SDK/platform/google_appengine/lib导出 PYTHONPATH=$PYTHONPATH:$GOOGLE_CLOUD_SDK/platform/google_appengine/lib/protorpc-1.0/protorpc

应用程序在本地和部署时运行,所以这看起来只是一个 lint 错误,但令人沮丧的是我无法解决它.

使用第三方库 状态:

<块引用>

标准环境中的 Python 运行时包括 Python标准库、App Engine 库和一些捆绑的第三方软件包.

因此,我假设App Engine 库"包括 protorpc,但我不确定.此外,将 Cloud Endpoints Frameworks 库添加到示例 API 只需要将 google-endpoints 安装到应用程序的 lib 目录:

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

我的观点是,我认为我没有安装任何东西,而且我认为我的(网络)应用程序的 lib 目录中没有遗漏任何东西.

解决方案

打开 Visual Studio Code 的设置文件 (settings.json) 并将库路径添加到 "python.autoComplete.extraPaths" 列表.

"python.autoComplete.extraPaths": ["~/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2","~/google-cloud-sdk/platform/google_appengine","~/google-cloud-sdk/lib","~/google-cloud-sdk/platform/google_appengine/lib/endpoints-1.0",~/google-cloud-sdk/platform/google_appengine/lib/protorpc-1.0"],

I'm using pylint in Visual Studio Code to develop a Google App Engine (GAE) Cloud Endpoint API in Python. I'm unable to resolve a lint error. I don't know what's causing the error, but at a guess, pylint cannot find the protorpc library?

The recommended fix in Troubleshooting Linting is to configure workspace settings to point to fully qualified python executable. I have done this, but the lint error remains.

protorpc itself is installed to:

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

...and this contains the remote.py module that cannot be imported:

__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

I've added this path to $PYTHONPATH (along with the 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

The application runs locally and also when deployed, so this appears to be just a lint error, but it's frustrating that I can't solve it.

Using third-party libraries states:

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

Because of this, I assumed 'the App Engine libraries' includes protorpc, but I'm unsure. Moreover, Adding the Cloud Endpoints Frameworks library to the sample API only requires google-endpoints be installed to the app's lib directory:

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

My point is, I don't think I've not installed something, and I don't think I'm missing anything in my (web) app's lib directory.

解决方案

Open the settings file of your Visual Studio Code (settings.json) and add the library path to the "python.autoComplete.extraPaths" list.

"python.autoComplete.extraPaths": [
    "~/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2",
    "~/google-cloud-sdk/platform/google_appengine",
    "~/google-cloud-sdk/lib",
    "~/google-cloud-sdk/platform/google_appengine/lib/endpoints-1.0",
    "~/google-cloud-sdk/platform/google_appengine/lib/protorpc-1.0"
],

这篇关于Visual Studio Code pylint:无法导入“protorpc"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆