我一直在尝试获取我的 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/