llSourcell / How_to_simulate_a_self_driving_car

This is the code for "How to Simulate a Self-Driving Car" by Siraj Raval on Youtube
431 stars 305 forks source link

AttributeError: module 'secrets' has no attribute 'token_bytes' (when I run the file drive.py with model.h5) #55

Open juwonlim opened 3 years ago

juwonlim commented 3 years ago

Hello. everyone here.

I just download the files from here.

and after model training,

I'm facing very difficult error.

command: python drive.py model-008.h5

result : Traceback (most recent call last): File "drive.py", line 8, in import socketio File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\socketioinit.py", line 3, in from .client import Client File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\socketio\client.py", line 7, in import engineio File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\engineioinit.py", line 5, in from .server import Server File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\engineio\server.py", line 6, in import secrets ImportError: No module named 'secrets'

so, I install python-ldap file (download from web sie)

and secrets (secrets requires python-ldap, but pip install is not working for it)

python ldap : https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap python_ldap-3.2.0-cp35-cp35m-win_amd64.whl

and I used the command 'pip install secrets' finally it is working. secrets install is success.

but finally, when I put the command

'python drive.py model.h5'

the result is below.

################################ 127.0.0.1 - - [25/Dec/2020 18:36:56] "GET /socket.io/?EIO=4&transport=websocket HTTP/1.1" 500 1324 0.001998 (3888) accepted ('127.0.0.1', 54090) Traceback (most recent call last): File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\eventlet\wsgi.py", line 573, in handle_one_response result = self.application(self.environ, start_response) File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\engineio\middleware.py", line 60, in call return self.engineio_app.handle_request(environ, start_response) File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\socketio\server.py", line 563, in handle_request return self.eio.handle_request(environ, start_response) File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\engineio\server.py", line 380, in handle_request transport, jsonp_index) File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\engineio\server.py", line 529, in _handle_connect sid = self.generate_id() File "C:\ProgramData\Anaconda3\envs\car-behavioral-cloning\lib\site-packages\engineio\server.py", line 503, in generate_id secrets.token_bytes(12) + self.sequence_number.to_bytes(3, 'big')) AttributeError: module 'secrets' has no attribute 'token_bytes'

###########################################

Previously, In the server.py file, I put the code of token_byte(). (source code from here : https://github.com/python/cpython/blob/master/Lib/secrets.py https://fossies.org/linux/Python/Lib/secrets.py )

because, server.py has a code of it. l

def generate_id(self): """Generate a unique session id.""" id = base64.b64encode( token_bytes(12) + self.sequence_number.to_bytes(3, 'big')) self.sequence_number = (self.sequencenumber + 1) & 0xffffff return id.decode('utf-8').replace('/', '').replace('+', '-')

The above def in the server.py using token_bytes() from secrets module. so, I just put a code into server.py which I got it from the web site. Finally, error is gone.

but nothing happen.

The car doesn't move.

Please help me!

keshasha commented 3 years ago

uninstall secrets and try pip install python-secrets

Subhainr commented 3 years ago

Not working

dev-cj commented 3 years ago

The same thing happening to me

huangqianfirst commented 3 years ago

Try to update python 3.5.2 to python 3.6. It work for me. @juwonlim @dev-cj @Subhainr

West6035 commented 3 years ago

hey,wondering how did you upgrade Python in the virtual environment

jasonchen2581 commented 2 years ago

hi I am facing the same issue that secrets module not founds ,any one solve this?

mohamedabdu71 commented 2 years ago

pip uninstall python-engineio pip install python-engineio==3.11.2

i did these two steps and error gone but car does not move ..