在Heroku中生成项目时出错(键名=':'中的字符无效)

2024-03-28 23:59:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我不能在Heroku建立我的项目,在Pipfile上崩溃。Heroku与我的Github存储库相链接,这是私有的,原因很明显。 我也尝试过其他方法,但是当我添加“worker:python”时bot.py公司“在Pipfile上,它根本无法构建。没有Pipfile.lock文件在我的项目上。 日志:

    -----> Python app detected
 !     No 'Pipfile.lock' found! We recommend you commit this into your repository.
-----> Need to update SQLite3, clearing cache
-----> Installing python-3.6.9
-----> Installing pip
-----> Installing dependencies with Pipenv 2018.5.18…
       Traceback (most recent call last):
         File "/app/.heroku/python/lib/python3.6/site-packages/pipenv/project.py", line 438, in _parse_pipfile
           return contoml.loads(contents)
         File "/tmp/build_97bd7e093c4db06e0905838cbf26d2d1/.heroku/python/lib/python3.6/site-packages/pipenv/patched/contoml/__init__.py", line 14, in loads
           tokens = tuple(lexer(text, is_top_level=True))
         File "/tmp/build_97bd7e093c4db06e0905838cbf26d2d1/.heroku/python/lib/python3.6/site-packages/pipenv/patched/prettytoml/lexer/__init__.py", line 108, in tokenize
           next_row, next_col, source[next_index:]))
       prettytoml.lexer.LexerError: failed to read the next token at (9, 4): : python bot.py
       worker: python bot.py


       During handling of the above exception, another exception occurred:

       Traceback (most recent call last):
         File "/app/.heroku/python/bin/pipenv", line 11, in <module>
           sys.exit(cli())
         File "/tmp/build_97bd7e093c4db06e0905838cbf26d2d1/.heroku/python/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
           return self.main(*args, **kwargs)
         File "/tmp/build_97bd7e093c4db06e0905838cbf26d2d1/.heroku/python/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
           rv = self.invoke(ctx)
         File "/tmp/build_97bd7e093c4db06e0905838cbf26d2d1/.heroku/python/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
           return _process_result(sub_ctx.command.invoke(sub_ctx))
         File "/tmp/build_97bd7e093c4db06e0905838cbf26d2d1/.heroku/python/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
           return ctx.invoke(self.callback, **ctx.params)
         File "/tmp/build_97bd7e093c4db06e0905838cbf26d2d1/.heroku/python/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
           return callback(*args, **kwargs)
         File "/app/.heroku/python/lib/python3.6/site-packages/pipenv/cli.py", line 402, in install
           selective_upgrade=selective_upgrade,
         File "/app/.heroku/python/lib/python3.6/site-packages/pipenv/core.py", line 1785, in do_install
           pre = project.settings.get('allow_prereleases')
         File "/app/.heroku/python/lib/python3.6/site-packages/pipenv/project.py", line 446, in settings
           return self.parsed_pipfile.get('pipenv', {})
         File "/app/.heroku/python/lib/python3.6/site-packages/pipenv/project.py", line 392, in parsed_pipfile
           parsed = self._parse_pipfile(contents)
         File "/app/.heroku/python/lib/python3.6/site-packages/pipenv/project.py", line 441, in _parse_pipfile
           return toml.loads(contents)
         File "/tmp/build_97bd7e093c4db06e0905838cbf26d2d1/.heroku/python/lib/python3.6/site-packages/pipenv/vendor/toml.py", line 176, in loads
           item + "'. Try quoting the key name.")
       toml.TomlDecodeError: Found invalid character in key name: ':'. Try quoting the key name.
 !     Push rejected, failed to compile Python app.
 !     Push failed

我的文件:

[packages] 
requests = "*"
python-telegram-bot = "*"

[scripts]
web: python bot.py
worker: python bot.py

对我来说似乎是对的,我不知道该怎么办。。。你知道吗


Tags: inpybuildappherokureturnlibpackages
1条回答
网友
1楼 · 发布于 2024-03-28 23:59:15

这里的问题是PipfilePipfile.lock文件 Pipfile文件用于指定Python应用程序或库的包要求,包括开发和执行。 文件语法为:

[[source]] # Here goes your package sources (where you are downloading your packages from).
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"

[packages] # Here goes your package requirements for running the application and its versions (which packages you will use when running the application).
requests = "*"
flask = "*"
pandas = "*"

[dev-packages] # Here goes your package requirements for developing the application and its versions (which packages you will use when developing the application)
wheel = "*"

[requires] # Here goes your required Python version.
python_version = "3.6"

Pipfile.lock文件 这个Pipfile.lock文件旨在基于Pipfile中存在的包指定应使用这些包的特定版本,从而避免自动升级相互依赖的包和破坏项目依赖树的风险。你知道吗

如果需要,请使用此命令Pipfile.lock文件存在。你知道吗

$ pipenv lock

您可以在Procfile中添加web: python bot.py

相关问题 更多 >