Visual Studio代码pylint:无法导入"protorpc" [英] Visual Studio Code pylint: Unable to import 'protorpc'
问题描述
我在 Python中的Cloud Endpoint API .我无法解决棉绒错误.我不知道是什么原因引起的错误,但据猜测, pylint 不能找到protorpc
库?
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?
对Linting进行故障排除中的建议修复方法是将工作区设置配置为指向完全合格的python可执行文件.我已经做到了,但是皮棉错误仍然存在.
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
本身已安装到:
~/google-cloud-sdk/platform/google_appengine/lib/protorpc-1.0/protorpc
...并且其中包含无法导入的remote.py
模块:
...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
我已将此路径添加到$PYTHONPATH
(以及厨房水槽):
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.
使用第三方库状态:
标准环境中的Python运行时包括Python 标准库,App Engine库以及一些捆绑在一起的库 第三方程序包.
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
,但不确定.此外,将Cloud Endpoints Frameworks库添加到示例API 仅需要将Google端点安装到应用程序的lib目录:
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
我的意思是,我不认为我没有安装任何东西,也不认为我(网络)应用的lib目录中缺少任何内容.
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.
推荐答案
打开Visual Studio代码(settings.json
)的设置文件,并将库路径添加到"python.autoComplete.extraPaths"
列表中.
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代码pylint:无法导入"protorpc"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!