Python: ImportError: /usr/local/lib/python3.8/lib-dynload/math.cpython-38-x86_64-linux-gnu.so: file too short - python-3.8

Im a beginner in Python and i try to import a math module but i get the following error and i dont understand what it is about :
ImportError: /usr/local/lib/python3.8/lib-dynload/math.cpython-38-x86_64-linux-gnu.so: file too short
can someone helps me please?
Thanks

Related

FileNotFoundError in Python3 (Code editor: Pycharm)

I have imported
import numpy as np
and I have used
xy = np.loadtxt('./Desktop/wine.csv', delimiter=',', dtype=np.float32, skiprows=1)
but Python3 is not able to read the file and I really do not know why. Can anyone help me please?
Can you try again by specifying the full file path?
/home/username/Desktop/wine.cvs

pandas-read-xml has error on 'json-normalize'

I saw there is a way to directly read XML files using pandas. I followed and used this package. However, I keep getting errors.
https://pypi.org/project/pandas-read-xml/
import pandas as pd
import pandas_read_xml as pdx
from pandas.io.json import json_normalize
The error was generated by last line and the error is
ImportError: cannot import name 'json_normalize'
I am using kernel python 3, can anyone tell me what was wrong with it?

What is the .optimizer package in Pytorch?

I am trying to write my own optimizer for pytorch and am looking at the source code https://pytorch.org/docs/stable/_modules/torch/optim/sgd.html#SGD
to get started. When I try to run the code for the SGD, I get an error on the line
from .optimizer import Optimizer, required. I've searched everywhere but I'm not sure where to obtain the .optimizer package. Any help here is greatly appreciated.
Here import .optimizer means import optimizer.py from the same directory as the current .py file, so this file

TypeError: Cannot convert pyarrow.lib.ChunkedArray to pyarrow.lib.Array

I am converting a csv file to feather type using the code as below,
import pandas as pd
import feather
df = pd.read_csv('myfile.csv')
feather.write_dataframe(df, 'myfile.feather')
myfile.csv is over 2G and when I run the code I get the error message as below:
File "table.pxi", line 705, in pyarrow.lib.RecordBatch.from_pandas
File "table.pxi", line 739, in pyarrow.lib.RecordBatch.from_arrays
TypeError: Cannot convert pyarrow.lib.ChunkedArray to pyarrow.lib.Array
I've looked at similar questions and have found that feather started to support large file over 2G recently. But my feather version is 0.4 so I think mine one is already able to support large file. Why do I get this error? Any ideas would be appreciated, thanks.

error importing numpy

I have strange error, when I try to import numpy:
Traceback (most recent call last):
File "/home/timo/malltul/mafet/src/mafet/core/pattern.py", line 7, in <module>
import numpy as np
File "/usr/lib/python2.6/dist-packages/numpy/__init__.py", line 147, in <module>
import ma
File "/usr/lib/python2.6/dist-packages/numpy/ma/__init__.py", line 44, in <module>
import core
File "/usr/lib/python2.6/dist-packages/numpy/ma/core.py", line 4850, in <module>
all = _frommethod('all')
File "/usr/lib/python2.6/dist-packages/numpy/ma/core.py", line 4824, in __init__
self.__doc__ = self.getdoc()
File "/usr/lib/python2.6/dist-packages/numpy/ma/core.py", line 4830, in getdoc
signature = self.__name__ + get_object_signature(meth)
File "/usr/lib/python2.6/dist-packages/numpy/ma/core.py", line 109, in get_object_signature
import inspect
File "/usr/lib/python2.6/inspect.py", line 39, in <module>
import tokenize
File "/usr/lib/python2.6/tokenize.py", line 38, in <module>
COMMENT = N_TOKENS
NameError: name 'N_TOKENS' is not defined
It seems that the cause of the problem is that my script is in my own package named core and whenever I try to import numpy there, I get the error. Importing works fine elsewhere.
The only solution I've got this far is to rename my 'core' package to something else. Why does this matter? Am I doing something wrong?
I'm using Python2.6 on Ubuntu 10.14 . Numpy version is 1.3.0 .
EDIT: Actually renaming my package does not fix it. Renaming token.py in my package fixes it. Sorry for the error.
I doubt this has anything to do with your core module or with numpy.
From the stack trace, it would appear that the problem is with the tokenize module, which is part of Python, not part of numpy. Tokenize does from token import * and then uses N_TOKENS that's defined in token.py.
First of all, I'd check that there's no stray module called token on your PYTHONPATH:
>>> import token
>>> token.__file__
'/usr/lib/python2.6/token.pyc'
If this picks up the above file yet you still get the problem, I'd suggest reinstalling Python.