I've been using keepass and libkeepass to access the key database via Python. Although the code works on linux it does not work on Windows, I receive this error relating to the keyfile:
with libkeepass.open(db_path, keyfile) as kdb:
File "C:\Python27\lib\contextlib.py", line 17, in __enter__
return self.gen.next()
File "build\bdist.win-amd64\egg\libkeepass\__init__.py", line 33, in open
File "build\bdist.win-amd64\egg\libkeepass\kdb4.py", line 380, in __init__
File "build\bdist.win-amd64\egg\libkeepass\kdb4.py", line 54, in __init__
File "build\bdist.win-amd64\egg\libkeepass\common.py", line 137, in __init__
File "build\bdist.win-amd64\egg\libkeepass\kdb4.py", line 383, in read_from
File "build\bdist.win-amd64\egg\libkeepass\kdb4.py", line 72, in read_from
File "build\bdist.win-amd64\egg\libkeepass\common.py", line 143, in read_from
File "build\bdist.win-amd64\egg\libkeepass\kdb4.py", line 191, in _decrypt
IOError: Master key invalid.
I had quite a bit of trouble getting libkeepass installed on windows as opposed to linux. Not sure if this effecting it, the library loads fine it just doesn't seem to be able to use the keyfile.
I'm open to suggestions for a better key database that has a more robust python API if one exists, it needs to be a free to use piece of software?
TIA
Related
I get the below error on several different lines when making commands from script through Streamlit app. The process is a function call to opencv script is called via "process_file" function. This is what generates the below error.
What I've tried:
I've tested script seperatly and it processes video fine
I've tried using python-headless and uninstalling regular opencv
processed_file = process_file(uploaded_file)
ERROR:
app/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 562, in _run_script
exec(code, module.__dict__)
File "app/app.py", line 116, in <module>
run_app()
File "/app.py", line 81, in run_app
processed_file = process_file(uploaded_file)
File "/app.py", line 70, in process_file
return inference.main(file)
File "app/inference.py", line 66, in main
cv.namedWindow(winName, cv.WINDOW_NORMAL)
I'm trying to parse some Java code in Python using ANTLRv4. I've tried to follow this post, but I get the following error:
File "/home/xxxxxxx/xxxxxxx/xxxxxxx/antlr/proto_antlr.py", line 14, in <module>
main()
File "/home/xxxxxxx/xxxxxxx/xxxxxxx/antlr/proto_antlr.py", line 9, in main
tree = parser.compilationUnit()
File "/home/xxxxxxx/xxxxxxx/xxxxxxx/antlr/Java8Parser.py", line 4182, in compilationUnit
self.enterRule(localctx, 62, self.RULE_compilationUnit)
File "/home/xxxxxxx/xxxxxxx/xxxxxxx/lib/python3.8/site-packages/antlr4/Parser.py", line 374, in enterRule
self._ctx.start = self._input.LT(1)
File "/home/xxxxxxx/xxxxxxx/xxxxxxx/lib/python3.8/site-packages/antlr4/CommonTokenStream.py", line 62, in LT
self.lazyInit()
File "/home/xxxxxxx/xxxxxxx/xxxxxxx/lib/python3.8/site-packages/antlr4/BufferedTokenStream.py", line 187, in lazyInit
self.setup()
File "/home/xxxxxxx/xxxxxxx/xxxxxxx/lib/python3.8/site-packages/antlr4/BufferedTokenStream.py", line 190, in setup
self.sync(0)
File "/home/xxxxxxx/xxxxxxx/xxxxxxx/lib/python3.8/site-packages/antlr4/BufferedTokenStream.py", line 112, in sync
fetched = self.fetch(n)
File "/home/xxxxxxx/xxxxxxx/xxxxxxx/lib/python3.8/site-packages/antlr4/BufferedTokenStream.py", line 124, in fetch
t = self.tokenSource.nextToken()
File "/home/xxxxxxx/xxxxxxx/xxxxxxx/lib/python3.8/site-packages/antlr4/Lexer.py", line 130, in nextToken
self._tokenStartLine = self._interp.line_number
AttributeError: 'LexerATNSimulator' object has no attribute 'line_number'
I can't figure out what I'm doing wrong. The file I'm trying to parse is proper Java, it's extracted from the docker-maven-plugin package. I've tried with other files, but I get the same error.
Any idea ?
Actually it was just a problem of violent refactorization... I've changed line to line_number in my code, and it actually changed it in librairies too. Changing it back to line cleared the problem.
Thanks to #Thomas Kläger for making me realize it.
I'm trying to convert the kitti dataset into the tensorflow .record. After I typed the command:
python object_detection/dataset_tools/create_kitti_tf_record.py
--lable_map_path=object_detection/data/kitti_label_map.pbtxt --data_dir=/Users/zhenglyu/Graduate/research/DataSet/kitti/data_object_image_2/testing/image_2
--output_path=/Users/zhenglyu/Graduate/research/DataSet/kitti2tf/train.record
validation_set_size=1000
I got this error:
Traceback (most recent call last): File
"object_detection/dataset_tools/create_kitti_tf_record.py", line 310,
in
tf.app.run() File "/Users/zhenglyu/tensorflow/lib/python3.6/site-packages/tensorflow/python/platform/app.py",
line 126, in run
_sys.exit(main(argv)) File "object_detection/dataset_tools/create_kitti_tf_record.py", line 307,
in main
validation_set_size=FLAGS.validation_set_size) File "object_detection/dataset_tools/create_kitti_tf_record.py", line 94,
in convert_kitti_to_tfrecords
label_map_dict = label_map_util.get_label_map_dict(label_map_path) File
"/Users/zhenglyu/Graduate/research/TensorFlow/model/research/object_detection/utils/label_map_util.py",
line 152, in get_label_map_dict
label_map = load_labelmap(label_map_path) File "/Users/zhenglyu/Graduate/research/TensorFlow/model/research/object_detection/utils/label_map_util.py",
line 132, in load_labelmap
label_map_string = fid.read() File "/Users/zhenglyu/tensorflow/lib/python3.6/site-packages/tensorflow/python/lib/io/file_io.py",
line 120, in read
self._preread_check() File "/Users/zhenglyu/tensorflow/lib/python3.6/site-packages/tensorflow/python/lib/io/file_io.py",
line 80, in _preread_check
compat.as_bytes(self.name), 1024 * 512, status) File "/Users/zhenglyu/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py",
line 519, in __exit
c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.NotFoundError:
data/kitti_label_map.pbtxt; No such file or directory
The file exists for sure. And I don't know why as I set the label_map_path to another one (object_detection/data/kitti_label_map.pbtxt), the path still remains the default setting (data/kitti_label_map.pbtxt).
I know there's a lot of related problem but none of the solutions that I found works for me. I used Virtualenv to install the tensorflow and using python 3.6. Could these be the problem? Thanks!
I don't have a definitive solution to this but here is what resolved it.
First, I copied the kitti_label_map.pbtxt into the data_dir. Then I also copied create_kitti_tf_record.py into the data_dir. And now I copied(this is what made it run in the end) the name and absolute path of the kitti_label_map.pbtxt and pasted it as label_map_path
I have no idea why but it worked.
I am trying to interface with an Ocean optics spectrometer using seabreeze (seabreeze) and pyseabreeze (pyseabreeze).
If I enter python from the command prompt (cmd) in windows and enter the following code line by line, it works. However, if I put it in a script (spec_test.py) and try running it from cmd.exe by using 'python spec_test.py', it will not work.
I have searched around a lot for similar problems but none seem to cover the issue I'm having. I am running Windows 7 64 bit, python 3.5.2 installed using anaconda. I also had to install pyusb and libusb to use pyseabreeze.
The code:
import seabreeze
seabreeze.use('pyseabreeze')
import seabreeze.spectrometers as sb
devs = sb.list_devices()
print(devs)
spec = sb.Spectrometer(devs[0])
print(spec.model)
and the error message I get:
[<SeaBreezeDevice USB2000PLUS:FLMS02379>]
Traceback (most recent call last):
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\pyseabreeze\interfaces\common.py", line 14, in decorated_func
return func(*args, **kwargs)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\pyseabreeze\interfaces\spectrometer.py", line 46, in open
self.open_device(device.handle)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\pyseabreeze\interfaces\communication.py", line 37, in open_device
device.set_configuration()
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\usb\core.py", line 869, in set_configuration
self._ctx.managed_set_configuration(self, configuration)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\usb\core.py", line 102, in wrapper
return f(self, *args, **kwargs)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\usb\core.py", line 148, in managed_set_configuration
self.backend.set_configuration(self.handle, cfg.bConfigurationValue)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\usb\backend\libusb0.py", line 493, in set_configuration
_check(_lib.usb_set_configuration(dev_handle, config_value))
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\usb\backend\libusb0.py", line 431, in _check
raise USBError(errmsg, ret)
usb.core.USBError: [Errno None] b'libusb0-dll:err [set_configuration] could not set config 1: win error: The parameter is incorrect.\r\n'
Traceback (most recent call last):
File "<ipython-input-9-ead886eb3666>", line 1, in <module>
runfile('C:/Users/Raman Lab/Python code/Spectrometers/spec_testing.py', wdir='C:/Users/Raman Lab/Python code/Spectrometers')
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/Raman Lab/Python code/Spectrometers/spec_testing.py", line 7, in <module>
spec = sb.Spectrometer(devs[0])
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\spectrometers.py", line 62, in __init__
self._open_device(device)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\spectrometers.py", line 90, in _open_device
lib.device_open(self._dev)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\pyseabreeze\wrapper.py", line 81, in device_open
return device.interface.open(device)
File "C:\Users\Raman Lab\AppData\Local\Continuum\Anaconda3\lib\site-packages\seabreeze\pyseabreeze\interfaces\common.py", line 23, in decorated_func
raise SeaBreezeError(msg)
SeaBreezeError: An error occured during opening.
Thanks for any help!
Edit:
For some reason I figured this out, thought it might help describe the issue. If I enter interactive python from cmd.exe and paste the code instead of typing it in manually, I get the same error. This makes me think (most likely I'm wrong) that it is somehow tied up with speed of imports. I tried adding a sleep for a few seconds in between lines 3 and 5, to simulate what happens when I am typing in the prompt, but that didn't help. I hope this was descriptive enough.
Your initial guess was not far off. I had exactly the same problem, however, on Windows 7 32bit with Python 2.7. The example code gchaks linked to was running fine.
When I tried executing the script several times in quick succession, the error message changed and pointed at a empty devices list. I added a delay of 2 seconds after
devs = sb.list_devices()
and that solved the problem. Your code was running just fine on a Linux machine btw.
Another hint: If your code should run once, but then you run into another error message, make sure you close the device connection or dis- and reconnect the spectrometer.
I am trying to open my tryton client but it is not working
the snapshot of my problem :
the text of the problem is:
File "./tryton", line 66, in <module>
tryton.client.TrytonClient().run()
File "/home/ghassen/work/tryton/tryton/client.py", line 101, in run
main.sig_login()
File "/home/ghassen/work/tryton/tryton/gui/main.py", line 910, in sig_login
res = DBLogin().run()
File "/home/ghassen/work/tryton/tryton/gui/window/dblogin.py", line 579, in run
if (self.profiles.get(profile_name, sectionname)
File "/usr/lib/python2.7/ConfigParser.py", line 618, in get
raise NoOptionError(option, section)
Tryton has a profile file where it saves the know connections, and from the error it seems that file is corrupted. You can find this file under ~/.config/tryton/x.y/profiles.cfg where x.y corresponds to you version number.
If you don't have any saved profile, you can remove this file and the client will recreate them when started another time.