I created a Python app, that you may find on GitHub. I wanted to test if I was able deploy it and chose Heroku, it's the first time I deploy something. Even if it works great locally it fails to deploy on Heroku with the following error TypeError: the JSON object must be str, not 'bytes'
. It seems that the error comes from lockfile = json.load(f)
in the buildpack.
Question
While reading through the errors related to json.load()
a question about why does this deplomyment failed rose: is Heroku's Python buildpack solely reserved for Python 2 application ?
Heroku's unsuccessful Build Log
The full log is:
Activity Feed Build Log
ID 4d444270-f24f-461c-9079-bcd9134cec62
-----> Python app detected
! The latest version of Python 3 is python-3.6.5 (you are using python-3.5.2, which is unsupported).
! We recommend upgrading by specifying the latest version (python-3.6.5).
Learn More: https://devcenter.heroku.com/articles/python-runtimes
-----> Installing pip
Traceback (most recent call last):
File "/app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51/vendor/pipenv-to-pip", line 23, in <module>
main()
File "/app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51/vendor/pipenv-to-pip", line 11, in main
lockfile = json.load(f)
File "/app/.heroku/python/lib/python3.5/json/__init__.py", line 268, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/app/.heroku/python/lib/python3.5/json/__init__.py", line 312, in loads
s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'
! Push rejected, failed to compile Python app
! Push failed
Pipfile
I specified I wanted to use Python 3.6.5
[[source]]
url = "https://pypi.python.org/simple"
[packages]
requests = { extras = ['socks'] }
[requires]
python_version = "3.6.5"
buildpack
I chose a Python buildpack in the settings:
Other informations
- versions used :
I use Python 3.5.2. Or at least I think so ! And here are the full requirements.
- Former deployment attempt
I don't know but I tried to deploy the app on OpenShift. The app the log shows it failing during dependency downloads, I think it's safe to say that it's memory related. I didn't tried to increase the build memory limit to allow if to build all the way to completion yet.
- Checked answers
I already checked
- TypeError: the JSON object must be str, not 'bytes'.
but I'm not sure I can ask them to use request's built-in
.json()
function:lockfile.json(f)
? - Giving error “the JSON object must be str, not 'bytes' ” The answer is quite the same but it makes me wonder if the buildpack is for Python 2