I wrote an algorithm using python and matplotlib that generates histograms from some text input data. When the number of data input is approx. greater than 15000, I get in the (append) line of my code:
mydata = []
for i in range(len(data)):
mydata.append(string.atof(data[i]))
the error:
Traceback (most recent call last):
File "get_histogram_picture.py", line 25, in <module>
mydata.append(string.atof(data[i]))
File "/usr/lib/python2.6/string.py", line 388, in atof
return _float(s)
ValueError: invalid literal for float(): -a
can it be an error in python ? What is the solution ?
Thanks
That's a data parsing error:
>>> float("-a")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: invalid literal for float(): -a
Python data structure size if only limited by the available memory.
Related
While the following code snippet of a python program generates a nice xml file:
from proc import create_SRXML
create_SRXML.create_xml()
This following does not generate the xml file (the line "import pumoni.visu.renders as visua" is spoiling the job)
from proc import create_SRXML
import pumoni.visu.renders as visua
create_SRXML.create_xml()
and getting error log as follows:
Traceback (most recent call last):
File "processor/analyze_all.py", line 26, in <module>
create_SRXML.create_xml()
File "/datas/repo/work/pul/process/create_SRXML.py", line 13, in
create_xml
b1 = pulvii.SubElement(m1, "element",len="4",
name="FileMetaInformationGroupLength", tag="0002,0000", vm="1",
vr="UL")
TypeError: SubElement() got multiple values for argument 'tag'
May I know what the problem here is?
I have installed the symbolic package. There are some python related errors in the command window of Octave when I try to use symbolic.Below is the output:
> pkg load symbolic
>> syms a
Symbolic pkg v2.9.0: Traceback (most recent call last):
File "<stdin>", line 28, in <module>
AttributeError: '_PrintFunction' object has no attribute '__globals__'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 12, in octoutput_drv
File "<stdin>", line 54, in octoutput
File "<stdin>", line 55, in octoutput
AttributeError: module 'sympy' has no attribute 'compatibility'
Closing the Python communications link.
error: Python exception: AttributeError: '_PrintFunction' object has no attribute '__globals__'
occurred in python_header import block.
Try "sympref reset" and repeat your command?
(consider filing an issue at https://github.com/cbm755/octsympy/issues)
error: called from
pycall_sympy__ at line 191 column 5
valid_sym_assumptions at line 38 column 10
assumptions at line 82 column 7
syms at line 97 column 13
>> Opening in existing browser session.
Any idea how i can troubleshoot this?
Thanks.
The error is a known bug (https://github.com/cbm755/octsympy/issues/1035)
You need to use an older version of sympy sunch as version 1.5.1
I am trying to open and load pickle file but by two ways. But every time I am getting an error.
Request you to please help.
First way :
enron_data = pickle.load(open("D:/New/ud120-projects/final_project/final_project_dataset.pkl", "r"))
Error: Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: a bytes-like object is required, not 'str'
Second Way :
enron_data = pickle.load(open("D:/New/ud120-projects/final_project/final_project_dataset.pkl", "rb"))
Error : Traceback (most recent call last):
File "<stdin>", line 1, in <module>
_pickle.UnpicklingError: the STRING opcode argument must be quoted
Request you to please help
If you are on Windows you have to use a raw string and backslashes like this:
r'D:\path\to\your\file'
I am trying ro run sphinx search with python but getting error
I try this code
python3
import sphinxapi
client = sphinxapi.SphinxClient()
client.SetServer('127.0.0.1',9312)
client.Query("english","language_index")
get an error
client.Query("english","language_index")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/sphinxapi/__init__.py", line 579, in Query
assert (len(self._reqs) == 0)
AssertionError
I have never split strings in Python before so I am not too sure what is going wrong here.
import pyowm
owm = pyowm.OWM('####################')
location = owm.weather_at_place('Leicester, uk')
weather = location.get_weather()
weather.get_temperature('celsius')
temperature = weather.get_temperature('celsius')
print(temperature[5:10])
Error received
sudo python weather.py
Traceback (most recent call last):
File "weather.py", line 10, in <module>
print(temperature[5:10])
TypeError: unhashable type
get_temperature returns a dictionary, which you're then trying to index with a slice object, which is not hashable. e.g.
>>> hash(slice(5, 10))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type
To get the temperature, you need to get it from the dictionary like this:
temperature['temp']