简体   繁体   English

Python Flasky找不到扭曲的模块错误

[英]twisted module not found error from Python Flasky

I am having trouble in running a flask file that is manager.py on Windows 10. Although I installed requirements, it still aborts an import error.What's funny is the errors are different in PyCharm and cmd. 我在Windows 10上运行烧瓶文件(即manager.py)时遇到麻烦。尽管已安装要求,但该文件仍会中止导入错误。有趣的是,PyCharm和cmd中的错误有所不同。 And I activated the same virtual environment.I will appreciate it if someone can help me! 我激活了相同的虚拟环境,如果有人可以帮助我,我将不胜感激!

In PyCharm: 在PyCharm中:

Traceback (most recent call last):
  File "C:/Users/Administrator/Desktop/Online-serial-debugging/manage.py", line 6, in <module>
    from app import create_app
  File "C:\Users\Administrator\Desktop\Online-serial-debugging\app\__init__.py", line 2, in <module>
    from flask.ext.twisted import twisted
  File "C:\Users\Administrator\Desktop\online\Online-serial-debugging\enve\lib\site-packages\flask\exthook.py", line 87, in load_module
    raise ImportError('No module named %s' % fullname)
ImportError: No module named flask.ext.twisted.twisted

Process finished with exit code 1

In CMD: 在CMD中:

(enve) C:\Users\Administrator\Desktop\online\Online-serial-debugging>python manage.py
Traceback (most recent call last):
  File "manage.py", line 5, in <module>
    from flask.ext.script import Manager
ImportError: No module named flask.ext.script

Here are my requirments.txt: 这是我的requirments.txt:

construct==2.5.2
dominate==2.1.16
Flask==0.10.1
Flask-Bootstrap==3.3.5.3
Flask-Moment==0.5.0
Flask-Twisted==0.1.1
Flask-Script==2.0.5
itsdangerous==0.24
Jinja2==2.7.3
MarkupSafe==0.23
observable==0.1.0
pyserial==2.7
six==1.10.0
Twisted==15.4.0
txsockjs==1.2.2
pypiwin32
Werkzeug==0.10.4
zope.interface==4.1.2

Please fix your import statement as follows, and could you try? 请按以下步骤修改您的import声明,您可以尝试吗?

from flask_script import Manager

EDIT 编辑

Sorry, even using flask.ext.{} , it seems still works. 抱歉,即使使用flask.ext.{} ,它似乎仍然有效。

If you run the following command, what come back? 如果运行以下命令,会返回什么?

pip install Flask-Script==2.0.5

It means that 'Flask-Script' was not installed, check your 'pip freeze'. 这意味着未安装“ Flask脚本”,请检查“ pip冻结”。 Was there any error when installing the requirements? 安装需求时是否有任何错误? If so, try to identify the issue. 如果是这样,请尝试找出问题。

Try installing it: 尝试安装它:

$ pip install Flask-Script

OK. 好。 The problem is solved.orz. 问题已解决。 My command line is : 我的命令行是:

python manage.py

Actually, I used the Python interpreter in system path by mistake.And I run this command : 实际上,我错误地在系统路径中使用了python解释器,然后运行以下命令:

./enve/Scripts/python.exe manage.py

There are no import errors again, thank you who answered me still. 再次没有导入错误,谢谢仍然回答我的人。

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

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