简体   繁体   English

Python和IntelliJ出现问题

[英]Trouble with Python and IntelliJ

I'm writing a Flask application in IntelliJ, and for some reason I can't get IntelliJ to recognize Flask extensions. 我正在IntelliJ中编写Flask应用程序,由于某种原因,我无法让IntelliJ识别Flask扩展。 And so this works just fine: 所以这很好用:

from flask import Flask, Response, request

But this does not: 但这不是:

from flask.ext.wtf import Form

It will recognize and autocomplete flask.ext but not any submodules. 它将识别并自动完成flask.ext但不会自动完成flask.ext模块。

Does anyone know what the problem could be? 有谁知道是什么问题?

More info: 更多信息:

  • I'm using virtualenv and installing dependencies via bin/pip install <dependency> . 我正在使用virtualenv并通过bin/pip install <dependency>
  • I'm using the Python 2.7.5 SDK 我正在使用Python 2.7.5 SDK
  • The modules that I'm trying to get IntelliJ to recognize have all been successfully installed. 我试图让IntelliJ识别的模块已全部成功安装。

PyCharm has difficulty completing flask.ext... because all flask.ext does is proxy imports at runtime, so the built-in static detection is faulty. PyCharm很难完成flask.ext...因为flask.ext所做的只是在运行时导入代理,因此内置的静态检测是有缺陷的。

For future reference, flask.ext is deprecated in favor of using the actual package import such as from flask_wtf import Form . 为了将来参考,不建议使用flask.ext ,而是使用实际的包导入,例如from flask_wtf import Form As of Flask 1.0 it has been removed completely. 从Flask 1.0开始,它已被完全删除。

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

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