naokishibuya / car-behavioral-cloning

Built and trained a convolutional network for end-to-end driving in a simulator using Tensorflow and Keras
MIT License
229 stars 136 forks source link

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

Open juwonlim opened 3 years ago

juwonlim commented 3 years ago

Hello. Mr.Naoki and everyone here.

I just using Mr.Naokishibuya's git file from here. after model training,

I'm facing very difficult error.

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\socketio__init.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\engineio\init__.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!

AserElkhateeb99 commented 3 years ago

@juwonlim did you solve secrets problem?

juwonlim commented 3 years ago

I gave up to use this git code. Instead of this, I use another code. finally it works!

https://github.com/hurtadosanti/BehavioralCloning

oggy786 commented 2 years ago

I gave up to use this git code. Instead of this, I use another code. finally it works!

https://github.com/hurtadosanti/BehavioralCloning

my code is run succesfully but the car does not move its not connect please help how you resolve this issue

varun-spectre commented 1 year ago

Is anyone able to fix this? I am facing similar issue. Any help is appreciated.