eng = matlab.engine.start_matlab()
for line in matcode:
eng.workspace(line, nargout=0)
res = eng.workspace['x']
eng.quit()
and matcode.txt object string is
'x = [1 1;1 2;1 3;1 4];'
Couldn't figure out why is this happening :(
Traceback (most recent call last):
File "lreg.py", line 14, in <module>
main()
File "lreg.py", line 10, in main
data = matlab_engine.start_engine(code_object)
File "/Users/hiteshkr/PycharmProjects/MLCO/matlab_engine.py", line 7, in start_engine
eng.workspace(line, nargout=0)
TypeError: 'MatlabWorkSpace' object is not callable
Related
Traceback (most recent call last):
File "F:\GAMES-MOVIE-VIDEO-MUSIC COLLECTION [OPTICAL-DIGITAL]\DIGITAL COPIES\QOBUZ MUSIC\Qo-DL-Reborn\qo-dl_reborn.py", line 21, in
client = qopy.Client()
File "F:\GAMES-MOVIE-VIDEO-MUSIC COLLECTION [OPTICAL-DIGITAL]\DIGITAL COPIES\QOBUZ MUSIC\Qo-DL-Reborn\qopy\qopy.py", line 16, in init
self.id, self.sec = self.cfg_setup(False)
File "F:\GAMES-MOVIE-VIDEO-MUSIC COLLECTION [OPTICAL-DIGITAL]\DIGITAL COPIES\QOBUZ MUSIC\Qo-DL-Reborn\qopy\qopy.py", line 163, in cfg_setup
id = spoofer.get_app_id()
File "F:\GAMES-MOVIE-VIDEO-MUSIC COLLECTION [OPTICAL-DIGITAL]\DIGITAL COPIES\QOBUZ MUSIC\Qo-DL-Reborn\spoofbuz.py", line 20, in get_app_id
return re.search(self.appId_regex, self.bundle).group("app_id")
AttributeError: 'NoneType' object has no attribute 'group'
Here's my code:
import pandas as pd
df2 = pd.DataFrame()
try:
df_task = df_task.append(df2, ignore_index = True)
except NameError:
df_task = df2
raise
It produces this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 540, in runfile
execfile(filename, namespace)
File "/home/cld_intern/.spyder2/.temp.py", line 12, in <module>
df_task = df_task.append(df2, ignore_index = True)
NameError: name 'df_task' is not defined
The except block is supposed to catch the NameError, but somehow the inclusion of "raise" without specifying the exception to raise produces a NameError. Why is it so?
This runs perfectly:
import pandas as pd
df2 = pd.DataFrame()
try:
df_task = df_task.append(df2, ignore_index = True)
except NameError:
df_task = df2
This runs as expected too:
import pandas as pd
df2 = pd.DataFrame()
try:
df_task = df_task.append(df2, ignore_index = True)
except NameError:
df_task = df2
raise Exception("error message")
With the following traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 540, in runfile
execfile(filename, namespace)
File "/home/cld_intern/.spyder2/.temp.py", line 15, in <module>
raise Exception("error message")
Exception: error message
in python 3:
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
NameError: name 'df_task' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
NameError: name 'df2' is not defined
in python2.7
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
NameError: name 'df2' is not defined
Are you sure you are using python 2.7?
Like mentioned in the comment, df2 is not defined i guess.
class house_crawl():
def __init__(self):
self.row=0
self.workbook = xlsxwriter.Workbook(self.getdesktoppath() + '\\house_price.xlsx')
self.worksheet1 = self.workbook.add_worksheet()
self.worksheet1.write_row(self.row,0,['address','describe1','describle2','price','avg_price'])
self.row+=1
def __call__(self, url):
self.page_crawl(url)
def __del__(self):
self.workbook.close()
def page_crawl(self,url):
page=requests.get(url)
tree=html.fromstring(page.text)
for house in tree.xpath('//*[#class="house-item clearfix"]'):
address=house.xpath('div[1]/p[3]/text()')[0]
address=re.sub('\r|\n| ','',address)
#print(address)浦东-潍坊崂山路571弄(旧址崂山东路571弄)
d1=[]
for i in house.xpath('div[1]/p[1]/child::*'):
d1.append(i.xpath('text()')[0])
st=','
d1=st.join(d1)
# print(d1)东欣高层,3室1厅,70平
d2=house.xpath('div[1]/p[2]/text()')
stringt=','
d2=stringt.join(d2)
d2 = re.sub('\r|\n| ','',d2)
#print(d2)南,中层,中装,1991年
price=house.xpath('div[2]/p[1]/text()')[0]
#print(price)580万
avg_price=house.xpath('div[2]/p[2]/text()')[0]
if '元/平' not in avg_price:
avg_price = house.xpath('div[2]/p[3]/text()')[0]
#print(avg_price)83400元/平
self.worksheet1.write_row(self.row, 0, [address,d1,d2,price,avg_price])
self.row+=1
def getdesktoppath(self):
return os.path.join(os.path.expanduser("~"), 'Desktop')
he exception thrown is:
Exception ignored in: <bound method house_crawl.__del__ of <__main__.house_crawl object at 0x000001A14533B940>>
Traceback (most recent call last):
File "D:/pythoncode/crawl/house.py", line 15, in __del__
File "C:\Anaconda3\lib\site-packages\xlsxwriter\workbook.py", line 311, in close
File "C:\Anaconda3\lib\site-packages\xlsxwriter\workbook.py", line 619, in _store_workbook
File "C:\Anaconda3\lib\site-packages\xlsxwriter\packager.py", line 131, in _create_package
File "C:\Anaconda3\lib\site-packages\xlsxwriter\packager.py", line 188, in _write_worksheet_files
File "C:\Anaconda3\lib\site-packages\xlsxwriter\xmlwriter.py", line 41, in _set_xml_writer
File "C:\Anaconda3\lib\codecs.py", line 895, in open
AttributeError: module 'builtins' has no attribute 'open'
It says the 'self.workbook.close()' in del is wrong.
I don't understand.......
please help me !
2022-07-06 20:02:33
2022-07-06 20:02:33 Traceback (most recent call last):
2022-07-06 20:02:33 File "/usr/lib/python3.8/encodings/__init__.py", line 31, in <module>
2022-07-06 20:02:33 File "/var/www/codecs.py", line 14, in <module>
2022-07-06 20:02:33 AttributeError
2022-07-06 20:02:33 :
2022-07-06 20:02:33 module 'builtins' has no attribute 'open'
2022-07-06 20:02:33
When trying to set up the DataIterator as explained on neon tutorial.
from neon.data import DataIterator
import numpy as np
X = np.random.rand(10000, 3072)
y = np.random.randint(1, 11, 10000)
train = DataIterator(X=X, y=y, nclass=10, lshape=(3, 32, 32))
I encountered a weird error:
ERROR:neon.data.dataiterator:DataIterator class has been deprecated and renamed"ArrayIterator" please use that name.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "neon/data/dataiterator.py", line 168, in __init__
super(DataIterator, self).__init__(*args, **kwargs)
File "neon/data/dataiterator.py", line 82, in __init__
self.Xdev = [self.be.array(x) for x in X]
AttributeError: 'NoneType' object has no attribute 'array'
I then tried with ArrayIterator, keeping X, y the same.
ArrayIterator(X=X, y=y, nclass=10, lshape=(3,32,32))
With the same NoneType error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "neon/data/dataiterator.py", line 82, in __init__
self.Xdev = [self.be.array(x) for x in X]
AttributeError: 'NoneType' object has no attribute 'array'
Why would this be the case? Is there an easy fix?
Fixed the problem by generating backend.
from neon.backends import gen_backend
be = gen_backend()
(...)
Suppose I am given the following traceback:
Traceback (most recent call last):
File "<wingdb_compile>", line 3, in <module>
File "C:\Python34\lib\ftplib.py", line 419, in login
resp = self.sendcmd('PASS ' + passwd)
File "C:\Python34\lib\ftplib.py", line 272, in sendcmd
return self.getresp()
File "C:\Python34\lib\ftplib.py", line 245, in getresp
raise error_perm(resp)
ftplib.error_perm: 530 Login incorrect.
I have managed to extract the Error details but what has stumped me is how would I extract the line:
File "<wingdb_compile>", line 3, in <module>
I was looking at methods in the trace back package but wondered if any one had experience with that here
The function traceback.format_exc is built primarily for this
This is like print_exc(limit) but returns a string instead of printing to a file.
>>> import traceback
>>> try:
... x = 2/0
... except:
... error = traceback.format_exc()
...
>>> error
'Traceback (most recent call last):\n File "<stdin>", line 2, in <module>\nZeroDivisionError: division by zero\n'
>>> linesoferror = error.split('\n')
>>> linesoferror
['Traceback (most recent call last):', ' File "<stdin>", line 2, in <module>', 'ZeroDivisionError: division by zero', '']
So now you wanted the first line then you can simply use
>>> linesoferror[1]
' File "<stdin>", line 2, in <module>'
Voila! You have what you want
ALERT - Valid for Python 2.4.1 and above