Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
juwonlim opened this issue Dec 25, 2020 · 4 comments

Comments

@juwonlim
Copy link

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.sequence_number + 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
Copy link

@juwonlim did you solve secrets problem?

@juwonlim
Copy link
Author

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

https://github.com/hurtadosanti/BehavioralCloning

@oggy786
Copy link

oggy786 commented Jun 9, 2022

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants