Error when creating own haar cascade model in python - python

I have allmy files ready to train my model but when i try to merge sample files
I get this error:
Traceback (most recent call last):
File "./tools/mergevec.py", line 170, in <module>
merge_vec_files(vec_directory, output_filename)
File "./tools/mergevec.py", line 120, in merge_vec_files
val = struct.unpack('<iihh', content[:12])
TypeError: a bytes-like object is required, not 'str'
i have my positive nad negative images ready and with
python ./tools/mergevec.py -v samples/ -o samples.vec
I try to merge my files but than i got above error.
And the answer that comes up on stackoverflow regarding this mistake did not work in my case

Related

Python 3.9.9 Error " 'module' object is not a callable' - I am trying to download and extract .tgz file

I am trying to download and extract some data in .tgz file which I need to proceed with my book.
But unfortunately the code does not work.
I am receiving this error:
Traceback (most recent call last):
File "C:...\Python39_SciKit_&_TF_chapter2\main.py",
line 67, in <module>
fetch_housing_data()
File "C:...\Python39_SciKit_&_TF_chapter2\main.py",
line 54, in fetch_housing_data
with tarfile(FILE) as tar_data:
TypeError: 'module' object is not callable
And the code is:
# fetching data
URL = 'https://raw.githubusercontent.com/ageron/handson-ml2/master/datasets/housing/housing.tgz'
FILE = 'housing.tgz'
FOLDER = 'datasets'
def fetch_housing_data():
if not os.path.isfile(FILE):
print(f'Downloading {URL} and saving as {FILE}...')
urllib.request.urlretrieve(URL, FILE)
print('Unpacking file...')
with tarfile(FILE) as tar_data:
tar_data.extractall(FOLDER)
print('Tgz data has been extracted')
else:
print('The file is already in the folder')
And I don't know why this line gives an error:`
with tarfile(FILE) as tar_data:
tar_data.extractall(FOLDER)
Since I was using very similar approach with zip files and it worked.
Why python recognizes this as not collable and how do I make it work?

Create an executable from Selenium Python for IE with Pyinstaller

I have created a set of python scripts that scrape information out of a website using Internet Explorer. This methodology while not ideal, is the only way I could get it to work as the site does not work well with other browsers and has single-sign on authentication which was difficult to deal with through requests. Anyways, it works. I'd like to be able to share with coworkers without them needing to install python or modify scripts.
I was able to create an executable of the scripts that works on my computer through pyinstaller. When I share with coworkers, though, the get an error "local variable 'browser' referenced before assignment." I tried referencing the IEWebdriverService.exe the binaries field of the pyinstaller .spec file. This caused the size of the .exe to grow so it did something..but it didn't solve the problem.
This is my first time creating an executable and I have really no idea how the IE Driver works so I'm stuck at the moment. Any help would be greatly appreciated. I'm open to using another tool than pyinstaller if that helps, I just found it the easiest to use of the alternatives. I'm using Python 3.5.
thanks.
Edit - Error Log
run # 1
['Part Number = 12649189']
Error
Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.ie.se
rvice.Service object at 0x0000000004D00D30>>
Traceback (most recent call last):
File "site-packages\selenium\webdriver\common\service.py", line 173, in __del_
_
File "site-packages\selenium\webdriver\common\service.py", line 145, in stop
AttributeError: 'Service' object has no attribute 'process'
['Part Number = 12649189']
Error
Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.ie.se
rvice.Service object at 0x0000000004D00D30>>
Traceback (most recent call last):
File "site-packages\selenium\webdriver\common\service.py", line 173, in __del_
_
File "site-packages\selenium\webdriver\common\service.py", line 145, in stop
AttributeError: 'Service' object has no attribute 'process'
['Part Number = 12649189']
Error
Exception ignored in: <bound method Service.__del__ of <selenium.webdriver.ie.se
rvice.Service object at 0x0000000004D00D30>>
Traceback (most recent call last):
File "site-packages\selenium\webdriver\common\service.py", line 173, in __del_
_
File "site-packages\selenium\webdriver\common\service.py", line 145, in stop
AttributeError: 'Service' object has no attribute 'process'
Traceback (most recent call last):
File "Parent_Part_W_UI.py", line 138, in <module>
File "Parent_Part_W_UI.py", line 23, in __init__
File "Parent_Part_W_UI.py", line 40, in init_window
File "Parent_Part_W_UI.py", line 122, in execute_main
UnboundLocalError: local variable 'browser' referenced before assignment

How to import time column from snowflake to jupyter notebook dataframe?

I need to import data from snowflake to Jupyter. In the dataset I have a time column which is derived from timestamp values.
Every time I try to import the data, Jupyter says the process failed and below is the error message.
How should I get around this issue?
ERROR:snowflake.connector.converter:Failed to convert: field T: TIME::76493.000000000
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/snowflake/connector/converter.py", line 88, in to_python
type_name=type_name))
AttributeError: 'SnowflakeConverter' object has no attribute '_TIME_to_python'
ERROR:snowflake.connector.cursor:failed to convert row to python
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/snowflake/connector/cursor.py", line 658, in __row_to_python
res += (self._connection.converter.to_python(col_desc, col),)
File "/usr/local/lib/python2.7/site-packages/snowflake/connector/converter.py", line 88, in to_python
type_name=type_name))
AttributeError: 'SnowflakeConverter' object has no attribute '_TIME_to_python'
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line string', (1, 0))
Can you check the Python Connector version? The error indicates TIME data type is not supported by Python Connector. TIME data type has been supported since v1.0.6. As of today, the latest version is 1.2.8:
https://pypi.python.org/pypi/snowflake-connector-python/
Here is an example of TIME data type in Jupyter notebook:
https://gist.github.com/smtakeda/e401c80d71f2da4aa7452d238c5ccffa

Python syntax error "cannot concatenate 'str' and 'NoneType' objects"

I found this script on the internet:
https://gist.github.com/gavsmi/dd31746e5847300b62da
Any idea why I am getting the following error message? It looks like a syntax error. I am still new to Python, so please help me point out what the problem is and how to fix it.
[root#ip-172-31-18-97 tmppython]# python snapshot.py
INFO:root:Finding snapshot for tag...
Traceback (most recent call last):
File "snapshot.py", line 164, in <module>
main()
File "snapshot.py", line 30, in main
snapshot = find_snapshot(args.tag_name, args.tag_value)
File "snapshot.py", line 47, in find_snapshot
snapshots = conn.get_all_snapshots(filters={'tag:' + tag_name: tag_value})
TypeError: cannot concatenate 'str' and 'NoneType' objects
You likely are not providing a 'tag_name' command line argument when running your script. Added arguments default to None in the argparse module, so 'args.tag_name' ('tag_name' in the scope where the error occurs) will be None unless you give it a value via the command line. If it is not clear, the “cannot concatenate 'str' and 'NoneType' objects” run-time error results from the attempted concatenation "'tag:' + tag_name", where 'tag_name' is None.

Randomly NoneType object is not callable error

Recently I've got this problem in my application:
File "main.py", line 31,
in File "app.pyc", line 205, in run
TypeError: 'NoneType' object is not callable"
My code:
xml = EXML()
for pid, product in store.products.items():
xml.addRow()
xml.addCell((product['name']).encode('utf-8'), "String")
xml.addCell((product['symbol']).encode('utf-8'), "String")
xml.addCell((product['brand_name']).encode('utf-8'), "String") # line 205
xml.addCell(str(product['price']), "String")
Python 2.7 32-bit
It's wired, because this showed up after ~1000 iterations, with out any previus problem.
This application scans online store to get current prices.
Firstly I thought that somewhere I missed someting, and as result there is None.encode('utf-8'), but no, and "".encode('utf-8') seems to work. Moreover, I can't reproduce this error on testing site, just sometimes shows up while hard-working with ~2500 products.
What are possible other sources of this error?
>>> None.encode
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'encode'
>>> None()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not callable
On the given line you would have to set one of the two functions called to None somehow. Are you sure it's not the next line, because overwriting str is a rather common error.
OK, solved, it's bit bizzare, but this error is caused by product['brand_name'] which is sometimes BeautifulSoup.tag ( tag this time ) instead of BeautifulSoup.NavigableString as I planned. I still don't understad why and wtf ?
Anywat, great thanks for response. :)

Categories

Resources