简体   繁体   English

Pylint 错误:导入 package 时模块中没有名称

[英]Pylint error: no name in module when import a package

I'm learning a little bit how function python, more specific Flask.我正在学习一点 function python,更具体的 Flask。

I'm creating a new project using flask , but when I create a new file and import Flask I receive this error: No name 'Flask' in module 'flask'pylint(no-name-in-module)我正在使用flask创建一个新项目,但是当我创建一个新文件并import Flask我收到此错误: No name 'Flask' in module 'flask'pylint(no-name-in-module)

I did read that, I need create a file called: __init__.py but I have this and the error keeps showing up.我确实读过,我需要创建一个名为: __init__.py的文件,但我有这个并且错误不断出现。

This is my actual code (very simple code, and folder/files structure):这是我的实际代码(非常简单的代码和folder/files结构): 在此处输入图像描述

Thanks for the help: :D感谢您的帮助::D

I tried this: Flask ImportError: No Module Named Flask , but this solution does not works for me.我试过这个: Flask ImportError: No Module Named Flask ,但这个解决方案对我不起作用。

在此处输入图像描述

在此处输入图像描述

I solved this changing my python interpreter.我解决了这个改变我的 python 解释器的问题。 I did uninstall pylint and install pylama and now all is fine!我确实卸载pylint并安装pylama ,现在一切都很好!

I installed flask on python 2.7 and run simple hello world script and it worked fine.我在python 2.7上安装了flask并运行简单的 hello world 脚本,它运行良好。 Then I updated python to python 3.8 and I got an error similar to yours:然后我将python更新为python 3.8 ,我得到了一个类似于你的错误:

Unable to import 'flask'pylint(import-error)

I simply uninstalled flask and installed again and it worked for me.我只是卸载flask并再次安装,它对我有用。 Run this two commands:运行这两个命令:

pip uninstall flask
pip install flask

Then export the FLASK_APP environment variable and run flask然后导出FLASK_APP环境变量并运行flask

set FLASK_APP=file.py
flask run

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

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