Reputation: 1562
Hi is there a compatibility issue with numpy 1.7 and 1.8? I am getting error with a npy that was created using python 2.7 and numpy 1.7. Now I use python 3.4 and numpy 1.8
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\numpy\lib\format.py", line 334, in read_array_header_1_0
d = safe_eval(header)
File "C:\Python34\lib\site-packages\numpy\lib\utils.py", line 1128, in safe_eval
ast = compiler.parse(source, mode="eval")
File "C:\Python34\lib\ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 1
{'descr': '<f8', 'fortran_order': False, 'shape': (51L,), }
^
SyntaxError: invalid syntax
Upvotes: 0
Views: 143
Reputation: 2220
The problem is in the value of shape key. In python 3 you can't add L after the declaration.
martin@martin-desktop:~$ python3
Python 3.4.2 (default, Oct 8 2014, 13:08:17)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 3
3
>>> 3L
File "<stdin>", line 1
3L
^
SyntaxError: invalid syntax
>>>
PEP 237, first drafted in 2001, introduced an effort to remove the distinction between int
and long
integers. The work was completed in a three-phased approach spanning Python 2.2 through 2.4. Python 3.0 added a final step by officially removing the long() type and long
literals (e.g., 123456789L
).
In places where you would use long(), int() is the replacement and it will store the value in the correct internal representation.
In places where you used the L
suffix to produce long
literals, removal of the L is necessary, otherwise a SyntaxError will be raised.
http://docs.pythonsprints.com/python3_porting/py-porting.html#long-integers
Upvotes: 2