I am trying to use the python module keyboard in a docker container for testing automation that emulates keyboard presses. However, this module continually returns an error in the docker container whereas it works fine in an ubuntu VM.
I have installed different commonly used docker containers and different versions of python. I get the same error. Sadly, google hasn't been as helpful as it usually is here.
Here's an easily reproducible version of what I've done:
docker run -t -d -u root --name docker_container python:3.7
echo $(docker exec -u root docker_container bash -c 'python3 -m keyboard' )
This returns the below error message:
/usr/local/lib/python3.7/site-packages/keyboard/_nixkeyboard.py:110: UserWarning: Failed to create a device file using `uinput` module. Sending of events may be limited or unavailable depending on plugged-in devices.
device = aggregate_devices('kbd')
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/site-packages/keyboard/_nixcommon.py", line 106, in start_reading
self.event_queue.put(device.read_event())
File "/usr/local/lib/python3.7/site-packages/keyboard/_nixcommon.py", line 83, in read_event
data = self.input_file.read(struct.calcsize(event_bin_format))
AttributeError: 'NoneType' object has no attribute 'read'
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.7/site-packages/keyboard/_nixcommon.py", line 106, in start_reading
self.event_queue.put(device.read_event())
File "/usr/local/lib/python3.7/site-packages/keyboard/_nixcommon.py", line 83, in read_event
data = self.input_file.read(struct.calcsize(event_bin_format))
AttributeError: 'NoneType' object has no attribute 'read'
Traceback (most recent call last):
File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.7/site-packages/keyboard/__main__.py", line 10, in <module>
keyboard.hook(print_event_json)
File "/usr/local/lib/python3.7/site-packages/keyboard/__init__.py", line 459, in hook
append(callback)
File "/usr/local/lib/python3.7/site-packages/keyboard/_generic.py", line 67, in add_handler
self.start_if_necessary()
File "/usr/local/lib/python3.7/site-packages/keyboard/_generic.py", line 35, in start_if_necessary
self.init()
File "/usr/local/lib/python3.7/site-packages/keyboard/__init__.py", line 194, in init
_os_keyboard.init()
File "/usr/local/lib/python3.7/site-packages/keyboard/_nixkeyboard.py", line 114, in init
build_tables()
File "/usr/local/lib/python3.7/site-packages/keyboard/_nixkeyboard.py", line 73, in build_tables
dump = check_output(['dumpkeys', '--keys-only'], universal_newlines=True)
File "/usr/local/lib/python3.7/subprocess.py", line 395, in check_output
**kwargs).stdout
File "/usr/local/lib/python3.7/subprocess.py", line 472, in run
with Popen(*popenargs, **kwargs) as process:
File "/usr/local/lib/python3.7/subprocess.py", line 775, in __init__
restore_signals, start_new_session)
File "/usr/local/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'dumpkeys': 'dumpkeys'
From what I understand, it can't access a uinput device / keyboard to be able to dump the keys. Is there a way to virtually simulate a keyboard in the container to allow this to work?
try to install the following:
apt-get install -y kmod kbd
since you need this to get dumpkeys
I'm trying to init repo of Android ROM, but it returns following error on Ubuntu 16.04:
$ repo init -u git://github.com/AOSiP/platform_manifest.git -b pie
Get git://github.com/AOSiP/platform_manifest.git
Traceback (most recent call last):
File "/media/exthdd/AOSIP/.repo/repo/main.py", line 547, in <module>
_Main(sys.argv[1:])
File "/media/exthdd/AOSIP/.repo/repo/main.py", line 522, in _Main
result = repo._Run(argv) or 0
File "/media/exthdd/AOSIP/.repo/repo/main.py", line 184, in _Run
result = cmd.Execute(copts, cargs)
File "/media/exthdd/AOSIP/.repo/repo/subcmds/init.py", line 426, in Execute
self._SyncManifest(opt)
File "/media/exthdd/AOSIP/.repo/repo/subcmds/init.py", line 188, in _SyncManifest
m._InitGitDir(mirror_git=mirrored_manifest_git)
File "/media/exthdd/AOSIP/.repo/repo/project.py", line 2395, in _InitGitDir
self._UpdateHooks()
File "/media/exthdd/AOSIP/.repo/repo/project.py", line 2416, in _UpdateHooks
self._InitHooks()
File "/media/exthdd/AOSIP/.repo/repo/project.py", line 2446, in _InitHooks
os.path.relpath(stock_hook, os.path.dirname(dst)), dst)
File "/media/exthdd/AOSIP/.repo/repo/platform_utils.py", line 195, in symlink
return os.symlink(source, link_name)
OSError: [Errno 38] Function not implemented
It works when running on system drive, but I don't have enough space there.
Drive had exFAT filesystem, error gone on ext4.
I have previously used Jupyter Notebook (python 2 and 3) on my mac. After not using it for a while, there seems to be a problem I am unable to fix. When starting the notebook from terminal using the command Jupyter notebook, and then select a notebook I want to work with, I get the error:
"A connection to the notebook server could not be established. The notebook will continue trying to reconnect. Check your network connection or notebook server configuration."
I am positive this has nothing to do with my internet connection (I have tried 2 machines connected to different networks).
I have read that the browser could be the problem, therefore I have installed Chrome and Firefox. However, I get this error when I am using Safari, Chrome, and Firefox.
Then I read about it being a proxy issue. I have tried to add the server address of the notebook to the No proxy fields of the advanced network preferences of my mac, and of the advanced setting on Firefox.
The only thing I can think of is that I am entering the wrong server address?
I do not know much about setting and errors in general, hopefully someone can provide me with some alternative options to get Jupyter working again.
Terminal output:
ValueError: signal only works in main thread
ERROR:tornado.application:Exception in callback <functools.partial object at 0x111e2b208>
Traceback (most recent call last):
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/tornado/ioloop.py", line 759, in _run_callback
ret = callback()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/tornado/stack_context.py", line 276, in null_wrapper
return fn(*args, **kwargs)
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/zmq/eventloop/zmqstream.py", line 536, in <lambda>
self.io_loop.add_callback(lambda : self._handle_events(self.socket, 0))
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/zmq/eventloop/zmqstream.py", line 450, in _handle_events
self._handle_recv()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/zmq/eventloop/zmqstream.py", line 480, in _handle_recv
self._run_callback(callback, msg)
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/zmq/eventloop/zmqstream.py", line 432, in _run_callback
callback(*args, **kwargs)
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/tornado/stack_context.py", line 276, in null_wrapper
return fn(*args, **kwargs)
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/ipykernel/kernelbase.py", line 283, in dispatcher
return self.dispatch_shell(stream, msg)
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/ipykernel/kernelbase.py", line 233, in dispatch_shell
self.pre_handler_hook()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/ipykernel/kernelbase.py", line 248, in pre_handler_hook
self.saved_sigint_handler = signal(SIGINT, default_int_handler)
ValueError: signal only works in main thread
[I 19:03:26.685 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
Traceback (most recent call last):
File "/Users/xxx/anaconda2/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/Users/xxx/anaconda2/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/ipykernel_launcher.py", line 16, in <module>
app.launch_new_instance()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/traitlets/config/application.py", line 658, in launch_instance
app.start()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/ipykernel/kernelapp.py", line 477, in start
ioloop.IOLoop.instance().start()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/tornado/ioloop.py", line 928, in start
raise RuntimeError("IOLoop is already running")
RuntimeError: IOLoop is already running
[I 19:03:29.696 NotebookApp] KernelRestarter: restarting kernel (2/5), new random ports
Traceback (most recent call last):
File "/Users/xxx/anaconda2/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/Users/xxx/anaconda2/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/ipykernel_launcher.py", line 16, in <module>
app.launch_new_instance()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/traitlets/config/application.py", line 658, in launch_instance
app.start()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/ipykernel/kernelapp.py", line 477, in start
ioloop.IOLoop.instance().start()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/tornado/ioloop.py", line 928, in start
raise RuntimeError("IOLoop is already running")
RuntimeError: IOLoop is already running
[I 19:03:32.712 NotebookApp] KernelRestarter: restarting kernel (3/5), new random ports
Traceback (most recent call last):
File "/Users/xxx/anaconda2/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/Users/xxx/anaconda2/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/ipykernel_launcher.py", line 16, in <module>
app.launch_new_instance()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/traitlets/config/application.py", line 658, in launch_instance
app.start()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/ipykernel/kernelapp.py", line 477, in start
ioloop.IOLoop.instance().start()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/tornado/ioloop.py", line 928, in start
raise RuntimeError("IOLoop is already running")
RuntimeError: IOLoop is already running
[W 19:03:33.717 NotebookApp] Timeout waiting for kernel_info reply from 2cf24420-719b-4666-ad9f-fcdf8db505f3
[E 19:03:33.721 NotebookApp] Uncaught exception in /api/kernels/2cf24420-719b-4666-ad9f-fcdf8db505f3/channels
Traceback (most recent call last):
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/tornado/websocket.py", line 498, in _run_callback
result = callback(*args, **kwargs)
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/notebook/services/kernels/handlers.py", line 262, in open
super(ZMQChannelsHandler, self).open()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/notebook/base/zmqhandlers.py", line 176, in open
self.send_ping, self.ping_interval, io_loop=loop,
TypeError: __init__() got an unexpected keyword argument 'io_loop'
[E 19:03:34.749 NotebookApp] Uncaught exception in /api/kernels/2cf24420-719b-4666-ad9f-fcdf8db505f3/channels
Traceback (most recent call last):
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/tornado/websocket.py", line 498, in _run_callback
result = callback(*args, **kwargs)
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/notebook/services/kernels/handlers.py", line 262, in open
super(ZMQChannelsHandler, self).open()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/notebook/base/zmqhandlers.py", line 176, in open
self.send_ping, self.ping_interval, io_loop=loop,
TypeError: __init__() got an unexpected keyword argument 'io_loop'
[I 19:03:35.724 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
[E 19:03:35.771 NotebookApp] Uncaught exception in /api/kernels/2cf24420-719b-4666-ad9f-fcdf8db505f3/channels
Traceback (most recent call last):
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/tornado/websocket.py", line 498, in _run_callback
result = callback(*args, **kwargs)
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/notebook/services/kernels/handlers.py", line 262, in open
super(ZMQChannelsHandler, self).open()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/notebook/base/zmqhandlers.py", line 176, in open
self.send_ping, self.ping_interval, io_loop=loop,
TypeError: __init__() got an unexpected keyword argument 'io_loop'
Traceback (most recent call last):
File "/Users/xxx/anaconda2/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/Users/xxx/anaconda2/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/ipykernel_launcher.py", line 16, in <module>
app.launch_new_instance()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/traitlets/config/application.py", line 658, in launch_instance
app.start()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/ipykernel/kernelapp.py", line 477, in start
ioloop.IOLoop.instance().start()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/tornado/ioloop.py", line 928, in start
raise RuntimeError("IOLoop is already running")
RuntimeError: IOLoop is already running
[E 19:03:36.791 NotebookApp] Uncaught exception in /api/kernels/2cf24420-719b-4666-ad9f-fcdf8db505f3/channels
Traceback (most recent call last):
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/tornado/websocket.py", line 498, in _run_callback
result = callback(*args, **kwargs)
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/notebook/services/kernels/handlers.py", line 262, in open
super(ZMQChannelsHandler, self).open()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/notebook/base/zmqhandlers.py", line 176, in open
self.send_ping, self.ping_interval, io_loop=loop,
TypeError: __init__() got an unexpected keyword argument 'io_loop'
[E 19:03:37.810 NotebookApp] Uncaught exception in /api/kernels/2cf24420-719b-4666-ad9f-fcdf8db505f3/channels
Traceback (most recent call last):
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/tornado/websocket.py", line 498, in _run_callback
result = callback(*args, **kwargs)
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/notebook/services/kernels/handlers.py", line 262, in open
super(ZMQChannelsHandler, self).open()
File "/Users/xxx/anaconda2/lib/python2.7/site-packages/notebook/base/zmqhandlers.py", line 176, in open
self.send_ping, self.ping_interval, io_loop=loop,
TypeError: __init__() got an unexpected keyword argument 'io_loop'
[W 19:03:38.733 NotebookApp] KernelRestarter: restart failed
[W 19:03:38.733 NotebookApp] Kernel 2cf24420-719b-4666-ad9f-fcdf8db505f3 died, removing from map.
[W 19:03:38.830 NotebookApp] 404 GET /api/kernels/2cf24420-719b-4666-ad9f-fcdf8db505f3/channels?session_id=3F75F379F865488D8379D3BB7FC0BF0F (::1): Kernel does not exist: 2cf24420-719b-4666-ad9f-fcdf8db505f3
[W 19:03:38.838 NotebookApp] 404 GET /api/kernels/2cf24420-719b-4666-ad9f-fcdf8db505f3/channels?session_id=3F75F379F865488D8379D3BB7FC0BF0F (::1) 12.00ms referer=None
[W 19:03:40.859 NotebookApp] Replacing stale connection: 2cf24420-719b-4666-ad9f-fcdf8db505f3:3F75F379F865488D8379D3BB7FC0BF0F
Running the following version of jupyter and tornado seemed to solve the issue:
Jupyter: 4.4.0
Tornado: 4.5.3
I needed to downgrade my version of tornado (which was 5.0.2)
I faced this problem too. My problem was because of a custom module name. I named the module 'copy.py.' My issue was solved when I renamed it.
I found a way out, Installing Python on my PC solved it. I didn't install python before installing anaconda
I was also facing the kernal related issues and all my problems were solved by installing jupyter notebook from anaconda navigator.
So,The best way to handle jupyter notebook related problems is to install jupyter notebook from anaconda navigator for your environment in which you want to run jupyter notebook. If you will install jupyter notebook from anaconda navigator then you will not face any problem.
I am trying to install Django CMS on windows. I am using following steps.
C:\Python34\Scripts\pip install djangocms-installer
E:\Projects\example>C:\Python34\Scripts\djangocms -p mysite mysite
But throws following error:
Creating the project
Please wait while I install dependencies
*****************************************************************
Check documentation at https://djangocms-installer.readthedocs.io
*****************************************************************
Traceback (most recent call last):
File "c:\python34\lib\site-packages\djangocms_installer\install\__init__.py",
line 95, in requirements
output = subprocess.check_output(['pip'] + args, stderr=subprocess.STDOUT)
File "c:\python34\lib\subprocess.py", line 607, in check_output
with Popen(*popenargs, stdout=PIPE, **kwargs) as process:
File "c:\python34\lib\subprocess.py", line 859, in __init__
restore_signals, start_new_session)
File "c:\python34\lib\subprocess.py", line 1114, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\python34\lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "c:\python34\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Python34\Scripts\djangocms.exe\__main__.py", line 9, in <module>
File "c:\python34\lib\site-packages\djangocms_installer\main.py", line 33, in
execute
verbose=config_data.verbose
File "c:\python34\lib\site-packages\djangocms_installer\install\__init__.py",
line 98, in requirements
logger.error('cmd : %s :%s' % (e.cmd, e.output))
AttributeError: 'FileNotFoundError' object has no attribute 'cmd'
I have searched on it but can't get any solution.
The root cause is this line:
output = subprocess.check_output(['pip'] + args, stderr=subprocess.STDOUT)
so put the PATH on the pip executable location and it should work:
set PATH=%PATH%;C:\Python34\Scripts
At first glance, sounds that the package is not very adapted to Windows environment... The double exception is not very nice, and calling pip without any path can be a problem.
I'm using ubuntu 13.10 running in a VM on OSX, python2.7 and GAE 1.8.8.
Lauching dev_appserver.py results in the following error:
INFO 2013-12-10 03:53:30,046 api_server.py:527] Saving search indexes
Traceback (most recent call last):
File "/home/ubuntu/xxxxxx/google_appengine/dev_appserver.py", line 197, in <module>
File "/home/ubuntu/xxxxxx/google_appengine/dev_appserver.py", line 193, in _run_file
File "/home/ubuntu/xxxxxx/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 872, in <module>
File "/home/ubuntu/xxxxxx/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 868, in main
File "/home/ubuntu/xxxxxx/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 707, in stop
File "/home/ubuntu/xxxxxx/google_appengine/google/appengine/tools/devappserver2/api_server.py", line 141, in quit
File "/home/ubuntu/xxxxxx/google_appengine/google/appengine/tools/devappserver2/api_server.py", line 528, in cleanup_stubs
File "/home/ubuntu/xxxxxx/google_appengine/google/appengine/api/search/simple_search_stub.py", line 984, in Write
File "/usr/lib/python2.7/tempfile.py", line 304, in mkstemp
File "/usr/lib/python2.7/tempfile.py", line 239, in _mkstemp_inner
OSError: [Errno 24] Too many open files: '/tmp/appengine.xxxxxx-hr-dev.ubuntu/tmpMVVXrH'
Any ideas?
Check the shared memory parameter, kern.sysv.shmseg on your linux system and set it right by increasing it.
To view the shared memory parameters, use:
sysctl -A | grep shm
To update that parameters, edit file:
sudo nano /etc/sysctl.conf
Refer to this SO answer for more information.