Python 3.8: "an integer is required (got type bytes)" when loading models saved under older Python versions
See original GitHub issueDescribe the bug
There is an issue loading trained agent files in Python 3.8.
Code example
I checked this on the rl-baselines3-zoo
repository.
(base) manifold$ python enjoy.py --algo sac --env Pendulum-v0
Loading latest experiment, id=1
Traceback (most recent call last):
File "enjoy.py", line 225, in <module>
main()
File "enjoy.py", line 141, in main
model = ALGOS[algo].load(model_path, env=env, **kwargs)
File "/home/manifold/stable-baselines3/stable_baselines3/common/base_class.py", line 561, in load
data, params, pytorch_variables = load_from_zip_file(path, device=device)
File "/home/manifold/stable-baselines3/stable_baselines3/common/save_util.py", line 390, in load_from_zip_file
data = json_to_data(json_data)
File "/home/manifold/stable-baselines3/stable_baselines3/common/save_util.py", line 164, in json_to_data
deserialized_object = cloudpickle.loads(base64_object)
TypeError: an integer is required (got type bytes)
System Info Describe the characteristic of your environment:
- SB3 downloaded from git trunk
- Python version 3.8.5
- PyTorch version 1.6.0
- Gym version: latest from git
- Cloudpickle 1.6.0
Additional context
I printed out info and saw that it occurs when loading the data key learning_rate
on the SAC example above. For policies trained using recent versions of SB3 it happens for lr_schedule
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
How to fix 'TypeError: an integer is required (got type bytes ...
This is happening because you're using python 3.8. The latest pip release of pyspark (pyspark 2.4.4 at time of writing) doesn't support ...
Read more >Fix - TypeError: an integer is required (got type bytes) - Kontext
When running PySpark 2.4.8 script in Python 3.8 environment with Anaconda, the following issue occurs: TypeError: an integer is required (got ...
Read more >ctypes — A foreign function library for Python — Python 3.11.1 ...
ctypes is a foreign function library for Python. It provides C compatible data types, and allows calling functions in DLLs or shared libraries....
Read more >mlflow.pyfunc — MLflow 2.0.1 documentation
pyfunc module defines a generic filesystem format for Python models and provides utilities for saving to and loading from this format. The format...
Read more >an integer is required (got type bytes) on python 3.8.5 ... - Reddit
i don't seem to locate how to upgrade my spark in ubuntu. I am using jupyter notebook. My java version is 11.0.11. ubuntu@ip-172-31-15-155:~$ ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
✋ Hi, CPython maintainer here. Unfortunately, there is nothing to be done in our side, as the signature of code objects is not considered stable between versions. The constructor is purpously not even documented and we have this advice here:
(https://docs.python.org/3/library/types.html#standard-interpreter-types)
You can also use this new convenience method that we added to make the transition easier for people using code objects:
https://docs.python.org/3/library/types.html#types.CodeType.replace
closing this in favor of #172 (and as it is not an issue coming from SB3)