问题描述
我正在研究: http://flask.pocoo.org/docs/1.0 /tutorial/
我在以下位置写了__init__.py
(代码在这里: http://codepad.org/4FGIE901 ) /flaskr/目录中,设置一个名为"venv"的虚拟环境并安装Flask.
I've written __init__.py
(code here: http://codepad.org/4FGIE901) in a /flaskr/ directory, set up a virtual environment called 'venv' and installed Flask.
然后我在命令行中在flaskr目录中运行了这些命令-如``运行应用程序''建议:(export FLASK_APP=flaskr
,export FLASK_ENV=development
,flask run
)
I then ran these commands — on the command line, in the flaskr directory – as 'Run the application' advises: (export FLASK_APP=flaskr
, export FLASK_ENV=development
, flask run
)
我应该看到的是Hello, World!
相反,出现以下错误:
Traceback (most recent call last):
File "/Users/David/Desktop/flaskr/venv/lib/python3.6/site-packages/flask/cli.py", line 330, in __call__
rv = self._load_unlocked()
File "/Users/David/Desktop/flaskr/venv/lib/python3.6/site-packages/flask/cli.py", line 317, in _load_unlocked
self._app = rv = self.loader()
File "/Users/David/Desktop/flaskr/venv/lib/python3.6/site-packages/flask/cli.py", line 372, in load_app
app = locate_app(self, import_name, name)
File "/Users/David/Desktop/flaskr/venv/lib/python3.6/site-packages/flask/cli.py", line 246, in locate_app
'Could not import "{name}".'.format(name=module_name)
flask.cli.NoAppException: Could not import "flaskr.flaskr".
简而言之,我不确定如何解决这样的错误或如何工作.也许我在venv中安装了什么以及这个特定项目需要什么?
Simply, I'm not sure how I should respond to or work upon fixing an error like this. Perhaps I have a mismatch in what I have installed in the venv and what this particular project requires?
喜欢此人:无法导入熊猫:TypeError
烧瓶:
-
/Users/David/Desktop/flaskr/venv/bin/Flask
- 版本:1.0.2
点:
-
from /Users/David/Desktop/flaskr/venv/lib/python3.6/site-packages (python 3.6)
- 版本:9.0.1
Python:
-
/Users/David/Desktop/flaskr/venv/bin/python
- 版本:3.6.0
推荐答案
我认为您位于错误的文件夹中.您可能做到了:
I think you are in the wrong folder. You probably did:
cd flask_tutorial/flaskr
您需要进入教程文件夹:
You need to go up to the tutorial folder:
cd ..
您应该在flask_tutorial
文件夹中而不是flask_tutorial/flaskr
中放置flask run
,因为您要从该文件夹而不是flaskr/flaskr
(不存在)中导入flaskr
.
You should flask run
in the flask_tutorial
folder rather than flask_tutorial/flaskr
because you want to import flaskr
from that folder, not flaskr/flaskr
(which doesn't exist).
这篇关于flask.cli.NoAppException:无法导入"flaskr.flaskr"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!