1
votes

I read these guides to create my project.

First, creating a tar zip file.I create many files in my project folder. setup.py

from setuptools import setup, find_packages

setup(
    name='WebMonitor',
    version='1.0',
    long_description=__doc__,
    packages=find_packages(),
    include_package_data=True,
    zip_safe=False,
    install_requires=['Flask>=0.12']
)

MANIFEST.in

include schema.sql
include __init__.py
include auth.py
include blog.py
include db.py
graft static
graft templates
global-exclude *.pyc

setup.cfg

[egg_info]
tag_build = .dev
tag_date = 1

[aliases]
release = egg_info -Db ''

Then I run this command python setup.py release sdist to build a release package.

Second, install and run this app.

  1. Create a virtual environment with the command virtualenv env
  2. Activate the env with env\Scripts\activate
  3. Install the release package by pip install WebMonitor-1.0.tar.gz
  4. set FLASK_APP=WebMonitor
  5. Then run my app flask run -h 127.0.0.1 -p 5001. I get an error output:

    • Serving Flask app "WebMonitor"
    • Environment: production WARNING: Do not use the development server in a production environment. Use a production WSGI server instead.
    • Debug mode: off Usage: flask run [OPTIONS]

    Error: Could not import "WebMonitor".

Does anyone know how to solve this problem? Thank you very much.

2

2 Answers

-1
votes

As it is production env in cmd,

set FLASK_APP=WebMonitor.py

set FLASK_ENV=development

-4
votes

First ensure that you are at the root of the application file. in case it persist, Deactivate the virtual environment then activate it.