I'm using Python 3.9.12 and I get error in the following line
os.exit()
the Error message is: AttributeError: module 'os' has no attribute 'exit'
os.exit() is not and was not a method of the os module.
You may confuse it with os._exit() or sys.exit()
make sure variable os not been overwrited, like filename or varable name ...
As from comment, exit is a built-in. So os.exit() becomes exit()
Related
File "hinted-mods.py", line 275, in __init__ options.recurse_modules.append(f) AttributeError: 'Values' object has no attribute 'recurse_modules'
I get this error when I do python nuitka-hints.py main.py in console
I used the hinted compilation from nuitka utilities found here :
https://github.com/Nuitka/NUITKA-Utilities/tree/master/hinted-compilation
nuitka options no longer has the "recurse_modules" attribute. it was replaced by "follow_modules".
In my case, I simply modified the code(in hinted-mods.py, replace all "recures_modules" to "follow_modules"), and it worked.
check this PR https://github.com/Nuitka/NUITKA-Utilities/pull/63
I am using cv2 version 4.0.0 and python version 3.7.2.
I am trying to subtract Background using this method cv2.createBackgroundSubtractorMOG2() and its working well.
But when I use cv2.createBackgroundSubtractorMOG() its not working its showing me
AttributeError: module 'cv2.cv2' has no attribute
'createBackgroundSubtractorMOG '.
I also tried cv2.BackgroundSubtractorMOG() but i got same error
AttributeError: module 'cv2.cv2' has no attribute
'BackgroundSubtractorMOG'.
and another subtraction method cv2.createBackgroundSubtractorGMG() also not working.
I also refer other stackoverflow answers but I didn't get solution.
MOG2 containts in main opencv repository. MOG and GMG are from opencv_contrib: https://github.com/opencv/opencv_contrib/tree/master/modules/bgsegm
there are two subtraction packages in opencv. BackgroundSubtractorMOG() it's at cv2.bgsegm.BackgroundSubtractorMOG(),to use you must install opencv-contrib-python
While creating a nested directory in Python 3.6 received following error:
AttributeError: 'module' object has no attribute 'mkdirs'
Sample code:
def create_sample_data():
os.mkdirs("/tmp/lambdadir/ProjectTemp/mynewtest")
f=open("/tmp/lambdadir/ProjectTemp/mynewtest/my_copy.txt","w+")
f.write("This is inside a directory")
f.close()
Please help.
There is no os.mkdirs. Perhaps you meant os.mkdir or os.makedirs instead?
After googling a bit, found that, its a Python version issue.
I changed code from os.mkdirs() to os.makedirs() and it worked.
Details: os module documentation
Credits:
buttscicles - Reddit
In 3.10 when I tried it I faced the same. seems it's not available,
so I used below code.
# The folder should not exist or else will throw FileExistsError
os.mkdir('Parent-folder')
# The parent folder is should be created before , or else throws FileNotFoundError:
os.mkdir('Parent-folder/SubFolder')
I use wxPython 4.0.0b1 GTK2 (Phoenix) on Ubuntu 16.04 with python3.5. I am getting the following error:
AttributeError: module 'wx' has no attribute 'AboutDialogInfo'.
The code is pretty straightforward with no complexity.
Use:
aboutInfo = wx.adv.AboutDialogInfo()
https://wxpython.org/Phoenix/docs/html/wx.adv.AboutDialogInfo.html#wx.adv.AboutDialogInfo
I'm experimenting with the threading function in python 3 to get my own pingtesting app/log working, so im following a youtube tutorial
When I've launched a python 3 interpreter, and run:
>>> import threading
>>> print_lock = threading.Lock()
It correctly returns
>>> print_lock
<_thread.lock object at 0x042093C8>
But when I use that piece of code in a script and try to run it as
python scriptName.py
I get an error saying the attribute Lock() doesn't exist
AttributeError: 'module' object has no attribute 'Lock'
How is this possible? I've verified what threading.Lock() returns when running the python interpreter, why isn't it recognized when I try to run it in a script and how can I get this running?
Did you happen to name your module (or another module in the working directory) threading.py? It would get imported ahead of the built-in threading, causing this exact problem.
Trying running:
print(threading.__file__)
in your module, I suspect you'll find it's not the Python built-in.