I'm new to Python and I want to run the Duplex tool (https://github.com/beurtschipper/Depix ). But the test version does not start, when I type an in the command line:
python depix.py -p images/testimages/testimage3_pixels.png -s images/searchimages/debruinseq_notepad_Windows10_closeAndSpaced.png -o output.png
an error occurs:
Traceback (most recent call last):
File "F:\Work\Projects\Python\Depix\Depix-main\depixlib\depix.py ", line 10, in <module>
from. import __version__
Error Importer error: an attempt at relative import without a known parent package
In the READMI written
sh
depix \
-p /path/to/your/input/image.png \
-s images/searchimages/debruinseq_notepad_Windows10_closeAndSpaced.png \
-o /path/to/your/output.png
But I do not know how to run it, please help
I had the same error and it looks like it is a directory structure problem.
You can fix it by adding depixlib where you import the modules.
depixlib\depix.py
from depixlib import __version__
from depixlib.functions import
from depixlib.LoadedImage import LoadedImage
from depixlib.Rectangle import Rectangle
Hope it fixed your problem!
Now, I get the following errors, but that's another story. 😅
LoadedImage.py
return cast(list[list[tuple[int, int, int]]], _imageData)
TypeError: 'type' object is not subscriptable
edit: Actually I fixed the above by changing the following line to:
Last line of LoadedImage.py file
return cast(list(list([int, int, int])), _imageData)
It was mentionned here: https://github.com/beurtschipper/Depix/pull/83
Cheers!
Related
I want to run nvidia-detect and capture the output in a list or even a string that I can do a string comparison of the output to what I require.
I need to know if the system requires kmod-nvidia or kmod-nvidia-340xx.
I have searched and came up with two possible ways of capturing the output of nvidia-detect.
My initial code was:
test=str(os.system('nvidia-detect'))
print test
my output is:
kmod-nvida
256
where 256 is the value of test.
So after searching I tried:
test2=subprocess.check_output('nvidia-detect', shell=True)
and get this error:
Traceback (most recent call last):
File "/home/emmdom/PycharmProjects/mycode/nvidia_update.py", line 8, in <module>
test2=subprocess.check_output('nvidia-detect')
AttributeError: 'module' object has no attribute 'check_output'
I got it work this is what ended up working for me. Thanks
import os
os.system('yum -y yum-plugin-nvidia nvidia-detect')
nvidia='kmod-nvidia'
nvidia_340='kmod-nvidia-340xx'
chk_nvidia=(os.popen('nvidia-detect').read()).rstrip()
print chk_nvidia
if chk_nvidia == nvidia:
print 'nvidia'
os.system('yum -y kmod-nvidia')
if chk_nvidia == nvidia_340:
print 'nvidia-340-xxx'
os.system('yum -y kmod-nvidia-340xx')
recently i have created this topic and did not get the answer.
after that i edited this and added 2 screenshots.
right now i tested another temporary email library and got the same error :((
this library :
pip install python-guerrillamail
code python 2.7:
from guerrillamail import GuerrillaMailSession
session = GuerrillaMailSession()
print session.get_session_state()['email_address']
print session.get_email_list()[0].guid
it seemed i cant never work like this email lib.
updated after remove email.pyc:
Traceback (most recent call last):
File "C:\Users\11\Desktop\untitle.py", line 1, in <module>
from guerrillamail import Guerrillamail
ImportError: cannot import name Guerrillamail
Your module email.py, is shadowing, or hiding, the email package in Python's standard library. This is causing the error: in the traceback you can see that an error is being reported when the statement import email is executed.
Rename your file to something else, for example myemail.py.
I changed the code to " from guerrillamail import * " that is worked. this code seems import all things to program, maybe it causes to be heavy and executing time.
thanks to #snakecharmerb .
I am trying to find a specific pathname and pass this into os.chdir so I can run a command in that directory. I won't know the exact pathname hence why I have to run the find command. I have tried several ways to do this and each comes with a new error. The code below is one of the ways I have tried, can anyone suggest the best way to do this? Or how to fix this error?
Source Code:
import os
import subprocess
os.system('find ~ -path "*MyDir" > MyDir.txt')
output = subprocess.check_output("cat MyDir.txt", shell=True)
os.chdir(output)
os.system("file * > MyDir/File.txt")
The error:
Traceback (most recent call last):
File "sub1.py", line 8, in <module>
os.chdir(output)
FileNotFoundError: [Errno 2] No such file or directory: b'/Users/MyhomeDir/Desktop/MyDir\n'
I know that directory exists and presume it has something to do with the b' and \n'. I just don't know what the problem is.
Get rid of the \n with strip:
output = subprocess.check_output("cat MyDir.txt", shell=True).strip()
os.chdir(output)
I have a python script like this:
#!/usr/bin/env python
from scapy.all import *
from ospf import *
def ourSend(packet):
sendp(packet,iface='eth1')
host1='10.0.3.2'
advr_routers='10.0.8.7'
host2='10.0.2.2'
sequence=0x80000918
link2host1 = OSPF_Link(id=host1,data='10.0.3.1',type=2,metric=1)
link2host2 = OSPF_Link(id=host2,data='10.0.2.2',type=2,metric=1)
link2victim = OSPF_Link(id="192.168.200.20",data="255.255.255.255",type=3,metric=1)
IPlayer=IP(src='10.0.1.2',dst='224.0.0.5')
OSPFHdr=OSPF_Hdr(src='10.0.6.1')
rogueLsa=Ether()/IPlayer/OSPFHdr/OSPF_LSUpd(lsacount=1,lsalist=[OSPF_Router_LSA(options=0x22,id='10.0.3.1',adrouter=advr_routers,seq=sequence,\
linkcount=3,linklist=[link2victim,link2host1,link2host2])])
ourSend(rogueLsa)
When I run it it has an scapy error.. So I resolved it with git pyrt...
now when I want to run the python script I have other error:
$ python scipt.py
WARNING: No route found for IPv6 destination :: (no default route?)
Traceback (most recent call last):
File "s.py", line 19, in <module>
link2host1 = OSPF_Link(id=host1,data='10.0.3.1',type=2,metric=1)
NameError: name 'OSPF_Link' is not defined
Thank you
I Should separately get ospf.py again and run my script.
This is what I tried and worked...
When you git pyrt The module OSPF_Link can't be added. SO I used the ospf.py again and problem is solved now....
I am trying to setup a program where when someone enters a command it will run that command which is a script in a sub folder called "lib".
Here is my code:
import os
while 1:
cmd = input(' >: ')
for file in os.listdir('lib'):
if file.endswith('.py'):
try:
os.system(str(cmd + '.py'))
except FileNotFoundError:
print('Command Not Found.')
I have a file: lib/new_user.py But when I try to run it I get this error:
Traceback (most recent call last):
File "C:/Users/Daniel/Desktop/Wasm/Exec.py", line 8, in <module>
exec(str(cmd + '.py'))
File "<string>", line 1, in <module>
NameError: name 'new_user' is not defined
Does anyone know a way around this? I would prefer if the script would be able to be executed under the same window so it doesn't open a completely new one up to run the code there. This may be a really Noob question but I have not been able to find anything on this.
Thanks,
Daniel Alexander
os.system(os.path.join('lib', cmd + '.py'))
You're invoking new_user.py but it is not in the current directory. You need to construct lib/new_user.py.
(I'm not sure what any of this has to do with windows.)
However, a better approach for executing Python code from Python is making them into modules and using import:
import importlib
cmd_module = importlib.import_module(cmd, 'lib')
cmd_module.execute()
(Assuming you have a function execute defined in lib/new_user.py)