构建失败的Python Flask应用缺少什么?

时间:2020-09-08 17:16:07

标签: python flask heroku

构建失败的原因可能是什么?我尝试了不同版本的MarkupSafe,但仍然失败。也尝试过运行不同的分支,所有构建都失败了。 它有版本问题吗?还有其他需要的库吗?对数据库使用postgres。

-----> Python app detected
     !     Python has released a security update! Please consider upgrading to python-3.6.12
           Learn More: https://devcenter.heroku.com/articles/python-runtimes
    -----> Requirements file has been changed, clearing cached dependencies
    -----> Installing python-3.6.4
    -----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2
    -----> Installing SQLite3
    -----> Installing requirements with pip
           Collecting alembic==0.9.6
             Downloading alembic-0.9.6.tar.gz (998 kB)
           Collecting arrow==0.12.0
             Downloading arrow-0.12.0.tar.gz (89 kB)
           Collecting blinker==1.4
             Downloading blinker-1.4.tar.gz (111 kB)
           Collecting click==6.7
             Downloading click-6.7-py2.py3-none-any.whl (71 kB)
           Collecting dateparser==0.6.0
             Downloading dateparser-0.6.0-py2.py3-none-any.whl (68 kB)
           Collecting dominate==2.3.1
             Downloading dominate-2.3.1.tar.gz (27 kB)
           Collecting feedparser==5.2.1
             Downloading feedparser-5.2.1.tar.bz2 (192 kB)
           Collecting Flask==0.12.2
             Downloading Flask-0.12.2-py2.py3-none-any.whl (83 kB)
           Collecting Flask-Bootstrap==3.3.7.1
             Downloading Flask-Bootstrap-3.3.7.1.tar.gz (456 kB)
           Collecting Flask-Login==0.4.1
             Downloading Flask-Login-0.4.1.tar.gz (14 kB)
           Collecting Flask-Mail==0.9.1
             Downloading Flask-Mail-0.9.1.tar.gz (45 kB)
           Collecting Flask-Migrate==2.1.1
             Downloading Flask_Migrate-2.1.1-py2.py3-none-any.whl (13 kB)
           Collecting Flask-PyMongo==0.5.1
             Downloading Flask_PyMongo-0.5.1-py3-none-any.whl (10.0 kB)
           Collecting Flask-Script==2.0.6
             Downloading Flask-Script-2.0.6.tar.gz (43 kB)
           Collecting Flask-SQLAlchemy==2.3.2
             Downloading Flask_SQLAlchemy-2.3.2-py2.py3-none-any.whl (16 kB)
           Collecting Flask-WTF==0.14.2
             Downloading Flask_WTF-0.14.2-py2.py3-none-any.whl (14 kB)
           Collecting gunicorn==19.7.1
             Downloading gunicorn-19.7.1-py2.py3-none-any.whl (111 kB)
           Collecting itsdangerous==0.24
             Downloading itsdangerous-0.24.tar.gz (46 kB)
           Collecting Jinja2==2.10
             Downloading Jinja2-2.10-py2.py3-none-any.whl (126 kB)
           Collecting Mako==1.0.7
             Downloading Mako-1.0.7.tar.gz (564 kB)
           Collecting MarkupSafe==1.0
             Downloading MarkupSafe-1.0.tar.gz (14 kB)
               ERROR: Command errored out with exit status 1:
                command: /app/.heroku/python/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-uzscpaqz/MarkupSafe/setup.py'"'"'; __file__='"'"'/tmp/pip-install-uzscpaqz/MarkupSafe/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-jupo_kuh
                    cwd: /tmp/pip-install-uzscpaqz/MarkupSafe/
               Complete output (5 lines):
               Traceback (most recent call last):
                 File "<string>", line 1, in <module>
                 File "/tmp/pip-install-uzscpaqz/MarkupSafe/setup.py", line 6, in <module>
                   from setuptools import setup, Extension, Feature
               ImportError: cannot import name 'Feature'
               ----------------------------------------
           ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
     !     Push rejected, failed to compile Python app.
     !     Push failed

1 个答案:

答案 0 :(得分:0)

尝试将MarkupSafe升级到最新版本:

    public void EmailErrorMsgTest()
    {
        //var testcase = "A problem has occurred on this web site. Please try again.  If this error continues, please contact support.";
        var testcase = "Resolution of the dependency failed, type = 'DealerSoft.Service.Interfaces.IIdentityService', name = '(none)'.Exception occurred while: Calling constructor DealerSoft.DataAccess.DbContext(DealerSoft.DataAccess.IConnectionFactory connectionFactory, DealerSoft.Framework.Resolver.IUserResolverService userResolverService).Exception is: Exception - Data Source = foo.DealerSoftwebfoo.com,1200; Initial Catalog = DatabaseFoo; User ID = UserIdFoo; Password = PasswordFoo; MultipleActiveResultSets = true---------------------------------------------- - At the time of the exception, the container was: Resolving DealerSoft.Service.Interfaces.IIdentityService,(none)Resolving parameter 'repository' of constructor DealerSoft.Service.Services.IdentityService(DealerSoft.DataAccess.Repository.Repository repository, DealerSoft.DataAccess.IUnitOfWork unitOfWork) Resolving DealerSoft.DataAccess.Repository.Repository,(none)Resolving parameter 'context' of constructor DealerSoft.DataAccess.Repository.Repository(DealerSoft.DataAccess.DbContext context) Resolving DealerSoft.DataAccess.DbContext,(none)Calling constructor DealerSoft.DataAccess.DbContext(DealerSoft.DataAccess.IConnectionFactory connectionFactory, DealerSoft.Framework.Resolver.IUserResolverService userResolverService)";

        testcase = SecurityRiskErrorMessageCleanup(testcase);
    }

    private string SecurityRiskErrorMessageCleanup(string errorMessage)
    {
        int startPos = -1;
        int endPos = -1;
        var msg = errorMessage.ToLower();

        // Remove database connection string.
        startPos = msg.IndexOf(@"data source =");
        if (startPos >= 0)
        {
            var tmpPos = msg.IndexOf(@"password =", startPos + 1);
            endPos = msg.IndexOf(";", tmpPos + 1);
            if (endPos > startPos && startPos >= 0)
            {
                var tmpStr = errorMessage.Substring(startPos, (endPos - startPos) + 1);
                errorMessage = errorMessage.Replace(tmpStr, "");
            }
        }
        startPos = -1;
        endPos = -1;

        // Future cleanup.
        // N/A.

        return errorMessage;
    }