Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.3K
Visualizações
flask run Error: While importing 'project', an ImportError was raised

I have project directory named Project, and project directory includes python files and html files et al., and want to deploy in the AWS ec2 ubuntu sever.when I run in the local is ok.

when run "flask run" under the Project directory, there is error in the ubuntu terminal.

flask run
 * Serving Flask app 'project' (lazy loading)
 * Environment: development
 * Debug mode: on
Usage: flask run [OPTIONS]
Try 'flask run --help' for help.

Error: While importing 'project', an ImportError was raised

I have set a .flaskenv file as following:

FLASK_APP=project
FLASK_ENV=development 
over 4 years ago · Santiago Trujillo
4 Respostas
Responde à pergunta

0

Did you installed your dependencies on your remote server? If yes, try installing your app as a module.

Given a the following directory structure:

/yourapplication
/yourApplicationMainFolder
    __init__.py
    /static
        style.css
    /templates
        layout.html
        index.html
        login.html
        ...

Create a setup.py file on /yourapplication/setup.py with:

from setuptools import setup

setup(
    name='yourApplicationMainFolder',
    packages=['yourApplicationMainFolder'],
    include_package_data=True,
    install_requires=[
        'flask',
],)

Install with pip:

pip install -e .

If that did not work, comment out all your imports in the main script and inspect one by one to see which one is the problem.

over 4 years ago · Santiago Trujillo Relatório

0

I have solved it, reinstall all libraries again.

over 4 years ago · Santiago Trujillo Relatório

0

To future readers: something that might not be obvious is you can get more details on the import error by doing the following:

  • Remove all import lines from your __init__.py file
  • Run flask and navigate to the page it is hosted on
  • While flask is running re-add the import lines to your __init__.py file and let flask update at run time
  • Refresh the page in your browser.

You should now get more detailed information in the browser as to which line is causing the import error along with a traceback.

over 4 years ago · Santiago Trujillo Relatório

0

In my case, there was an error in importing a specific library on FLASK_APP file. Running the command python app.py as jluu suggested will help you to know exactly when the ImportError happens.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda