PyInstaller and pykeyboard aren't working together - python

I have PyInstaller and pykeyboard on my computer. I am trying to create a helpful python program and compile it in to a Linux executable with PyInstaller.
Every time I do this, so long as pykeyboard is imported in the script, it creates the executable, but the executable does not run. It comes back with an error.
I've tried compiling my script without pykeyboard and it works, but I would really like to use pykeyboard and get past this error.
Error shown below.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/root/Desktop/Python/Modules/PyInstaller/PyInstaller-2.1/PyInstaller/loader/pyi_importers.py", line 270, in load_module
File "/home/abigor/Desktop/Scripting/Python/Modules/PyInstaller/PyInstaller-2.1/test/build/test/out00-PYZ.pyz/pykeyboard", line 37, in <module>
File "/root/Desktop/Python/Modules/PyInstaller/PyInstaller-2.1/PyInstaller/loader/pyi_importers.py", line 270, in load_module
File "/home/abigor/Desktop/Scripting/Python/Modules/PyInstaller/PyInstaller-2.1/test/build/test/out00-PYZ.pyz/pykeyboard.x11", line 21, in <module>
File "/root/Desktop/Python/Modules/PyInstaller/PyInstaller-2.1/PyInstaller/loader/pyi_importers.py", line 270, in load_module
File "/home/abigor/Desktop/Scripting/Python/Modules/PyInstaller/PyInstaller-2.1/test/build/test/out00-PYZ.pyz/Xlib.XK", line 63, in <module>
File "/home/abigor/Desktop/Scripting/Python/Modules/PyInstaller/PyInstaller-2.1/test/build/test/out00-PYZ.pyz/Xlib.XK", line 44, in load_keysym_group
ImportError: No module named keysymdef.miscellany
I should also note that the pykeyboard module for Python is actually named "PyUserInput", but to import it from Python you must import "pykeyboard". I forgot to mention that earlier.

Related

Cannot able to run cqlsh due to python attribute error

Cannot able to execute the command cqlsh in mac m1 based system.
% bin/cqlsh
Traceback (most recent call last):
File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/cqlsh.py", line 159, in <module>
from cqlshlib import cql3handling, cqlhandling, pylexotron, sslhandling, cqlshhandling
File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/cql3handling.py", line 19, in <module>
from cqlshlib.cqlhandling import CqlParsingRuleSet, Hint
File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/cqlhandling.py", line 23, in <module>
from cqlshlib import pylexotron, util
File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/pylexotron.py", line 342, in <module>
class ParsingRuleSet:
File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/pylexotron.py", line 343, in ParsingRuleSet
RuleSpecScanner = SaferScanner([
^^^^^^^^^^^^^^
File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/saferscanner.py", line 91, in __init__
s = re.sre_parse.State()
^^^^^^^^^^^^
AttributeError: module 're' has no attribute 'sre_parse'
Looks like there may have been a breaking change introduced to Python's synchronized regex engine (SRE) with Python 3.11. I have created a ticket for this on the Cassandra project (CASSANDRA-18088).
In the interim, downgrade your local Python to 3.10, and you should be fine.

Nameko and ImportError

There was a problem when starting a microservice written in the Nameko framework.
When starting the microservice via the command
nameko run name_file_with_class_microservice
The following exception is thrown:
Traceback (most recent call last):
File "/home/user/.pyenv/versions/project/bin/nameko", line 33, in <module>
sys.exit(load_entry_point('nameko==2.12.0', 'console_scripts', 'nameko')())
File "/home/user/.pyenv/versions/project/lib/python3.9/site-packages/nameko/cli/main.py", line 112, in main
args.main(args)
File "/home/user/.pyenv/versions/project/lib/python3.9/site-packages/nameko/cli/commands.py", line 110, in main
main(args)
File "/home/user/.pyenv/versions/project/lib/python3.9/site-packages/nameko/cli/run.py", line 181, in main
import_service(path)
File "/home/user/.pyenv/versions/project/lib/python3.9/site-packages/nameko/cli/run.py", line 46, in import_service
__import__(module_name)
File "./main.py", line 18, in <module>
from commands.object import ObjectUpdateCommand, ObjectExportCommand
File "./commands/object/__init__.py", line 1, in <module>
from .object_export import ObjectExportCommand
File "./commands/object/object_export.py", line 6, in <module>
from ...exception import ProxyException
ImportError: attempted relative import beyond top-level package
I understand this has to do with the "sys.path" variable and where the launch is coming from. However, I do not understand how to make imports workable, both for the entire project as a whole, and for a separate microservice in it (yes, microservices are combined into one repository, for each of which its own docker-file is written)
Everything works if you specify an absolute path relative to the starting point of the microservice. However, this is not suitable for the whole project, PyCharm indicates import curves, autocompletion does not work, and so on.

importing pywinauto.application throws error while trying to run using python 3.5.4

I was trying to execute the following command on windows 10 machine using python 3.5.4,
from pywinauto.application import Application
Following is the error which i was receiving
Traceback (most recent call last):
File "C:/Users/bizact/Desktop/PSAV/test.py", line 1, in <module>
from pywinauto.application import Application
File "C:\Program Files\Python35\lib\site-packages\pywinauto\__init__.py", line 72, in <module>
from . import findwindows
File "C:\Program Files\Python35\lib\site-packages\pywinauto\findwindows.py", line 42, in <module>
from . import controls
File "C:\Program Files\Python35\lib\site-packages\pywinauto\controls\__init__.py", line 36, in <module>
from . import uiawrapper # register "uia" back-end (at the end of uiawrapper module)
File "C:\Program Files\Python35\lib\site-packages\pywinauto\controls\uiawrapper.py", line 46, in <module>
from ..uia_defines import IUIA
File "C:\Program Files\Python35\lib\site-packages\pywinauto\uia_defines.py", line 35, in <module>
import comtypes.client
File "C:\Program Files\Python35\lib\site-packages\comtypes\client\__init__.py", line 33, in <module>
gen_dir = _find_gen_dir()
File "C:\Program Files\Python35\lib\site-packages\comtypes\client\_code_cache.py", line 71, in _find_gen_dir
result = os.path.abspath(gen_path[-1])
IndexError: list index out of range
Is there a way i can fix this ?
Try running the script with administrative privileges. Just by looking at the traceback it looks like some cached files that pywinauto import tried to write but later on it wasn't found, and generally the script can't write the file due to permissions. If the above don't work, try installing python somewhere else (C:/Python with full privileges in order to isolate the issue)
This is comtypes issue. It will be fixed soon (EDIT: fixed in comtypes==1.1.7). You can downgrade to one of previous versions: pip install comtypes==1.1.2. Or run script as Administrator as Rodolfo suggested (disabling UAC may not help, need to say explicitly to "run as Administrator" by popup menu).

Python, py2exe, & pyopengl ImportError: No module named win32

When I try to build an exe using py2exe, it builds but when i try to run the exe it throws this error:
Traceback (most recent call last):
File "main.py", line 4, in <module>
File "OpenGL\GL\__init__.pyc", line 3, in <module>
File "OpenGL\GL\VERSION\GL_1_1.pyc", line 10, in <module>
File "OpenGL\platform\__init__.pyc", line 35, in <module>
File "OpenGL\platform\__init__.pyc", line 26, in _load
File "OpenGL\plugins.pyc", line 14, in load
File "OpenGL\plugins.pyc", line 28, in importByName
ImportError: No module named win32
It only does this when I use pyopengl, It builds and runs perfectly with pygame and almost any other library/module I have used.
My setup.py script looks like this:
from distutils.core import setup
import py2exe
setup(console=['main.py'])
I am on Windows 7 64bit
Actually, After another hour or so of searching I found the solution!
For anyone else who has this problem: http://www.py2exe.org/index.cgi/PyOpenGL

ImportError: No module named Scientific_numerics_package_id

I am trying to compile a python script for visualization of protein molecules using py2exe module. I've python2.7 running in win7 x64. When I try to execute the compiled file, it gives this error:-
C:\Python27\dist>visualn.exe
Traceback (most recent call last):
File "visualn.py", line 19, in <module>
File "MMTK\__init__.pyc", line 39, in <module>
File "Scientific\Geometry\__init__.pyc", line 30, in <module>
File "Scientific\Geometry\VectorModule.pyc", line 9, in <module>
File "Scientific\N.pyc", line 1, in <module>
ImportError: No module named Scientific_numerics_package_id
Without compiling I can run the script successfully. I've already installed scientific,MMTK modules. I got somewhere in the internet that Scientific_numerics_package_id module is available in netCDF4, so I installed that also but no good.
Any idea about the error?
You need the python-netcdf package.

Categories

Resources