python - heroku python3 : ImportError: No module named 'encodings'

标签 python heroku encoding python-3.4 reddit

我一直在尝试获取我的 python3 reddit bot现在在 heroku 上工作了一段时间,但我一直遇到这个错误:

~ $ python3
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted (core dumped)

当我在远程 bash session 中运行 python3 时(通过 heroku run bash ),这尤其会发生。

heroku 日志 输出:

2015-03-29T09:41:23.669871+00:00 heroku[bot.1]: Starting process with command `python3 allb.py`
2015-03-29T09:41:24.315878+00:00 heroku[bot.1]: State changed from starting to up
2015-03-29T09:41:24.978050+00:00 app[bot.1]: Fatal Python error: Py_Initialize: Unable to get the locale encoding
2015-03-29T09:41:24.978079+00:00 app[bot.1]: ImportError: No module named 'encodings'
2015-03-29T09:41:25.811735+00:00 heroku[bot.1]: State changed from up to crashed
2015-03-29T09:41:25.801807+00:00 heroku[bot.1]: Process exited with status 134

我尝试将运行时设置为 3.4,并寻找与问题类似的解决方案。一些消息来源说 $PYTHONPATH 必须为 nil,heroku 上的 $PYTHONPATH 的值为 /app//

这可能是一些愚蠢的错误,但我找不到它。

最佳答案

您需要在 runtime.txt 文件中指定您的 python 版本。

https://devcenter.heroku.com/articles/python-runtimes

然后在推送时你会看到:

远程:-----> 发现 python-2.7.13,删除

远程:-----> 安装 python-3.6.1

关于python - heroku python3 : ImportError: No module named 'encodings' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29327747/

相关文章:

python - 不断重绘wxPython元素

python - Django 中的模拟请求

ruby-on-rails - 无法安装 json - Ubuntu 14.04 - Rails

ruby - 如何使用 Mongoid3 为 15k 用户解决 "out of memory"错误和 'heroku run console'?

python - 为什么即使使用编码也无法在 python 中显示汉字?

python - 如何对整个列表进行字符串格式化?

python - 哪个python正在运行?

logging - Heroku Redis 日志很嘈杂——如何过滤掉它们?

python - Flask JSONEncoder 将 ensure_ascii 设置为 False

haskell - 从Haskell中的(预序)位串重建霍夫曼树