I've installed anaconda for python 3.7.4, I wrote this code to check all the libraries version:
print('Python: {}'.format(sys.version))
# scipy
import scipy
print('scipy: {}'.format(scipy.__version__))
# numpy
import numpy
print('numpy: {}'.format(numpy.__version__))
# matplotlib
import matplotlib
print('matplotlib: {}'.format(matplotlib.__version__))
# pandas
import pandas
print('pandas: {}'.format(pandas.__version__))
# scikit-learn
import sklearn
print('sklearn: {}'.format(sklearn.__version__))
And I got this error:
Traceback (most recent call last):
File "C:\Users\andre\AppData\Roaming\Python\Python37\site-packages\pandas\__init__.py", line 30, in <module>
from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
File "C:\Users\andre\AppData\Roaming\Python\Python37\site-packages\pandas\_libs\__init__.py", line 3, in <module>
from .tslibs import (
File "C:\Users\andre\AppData\Roaming\Python\Python37\site-packages\pandas\_libs\tslibs\__init__.py", line 3, in <module>
from .conversion import localize_pydatetime, normalize_date
ModuleNotFoundError: No module named 'pandas._libs.tslibs.conversion'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:/Users/andre/Desktop/ML programs/test.py", line 13, in <module>
import pandas
File "C:\Users\andre\AppData\Roaming\Python\Python37\site-packages\pandas\__init__.py", line 38, in <module>
"the C extensions first.".format(module)
ImportError: C extension: No module named 'pandas._libs.tslibs.conversion' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace
--force' to build the C extensions first.
What I have to do to solve it?
Related
I found several questions about the same issue here and here
from pyfinance.ols import PandasRollingOLS
I get the following error:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/pyfinance/utils.py", line 78, in <module>
from pandas.tseries.frequencies import FreqGroup, get_freq_code
ImportError: cannot import name 'FreqGroup' from 'pandas.tseries.frequencies' (/usr/local/lib/python3.8/site-packages/pandas/tseries/frequencies.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.8/site-packages/pyfinance/__init__.py", line 32, in <module>
from .returns import TFrame, TSeries # noqa
File "/usr/local/lib/python3.8/site-packages/pyfinance/returns.py", line 42, in <module>
from pyfinance import ols, utils
File "/usr/local/lib/python3.8/site-packages/pyfinance/ols.py", line 15, in <module>
from pyfinance import utils
File "/usr/local/lib/python3.8/site-packages/pyfinance/utils.py", line 80, in <module>
from pandas._libs.tslibs.frequencies import FreqGroup, get_freq_code
ModuleNotFoundError: No module named 'pandas._libs.tslibs.frequencies'
I tried uninstalling and reinstalling pandas versions 1.1.3, 1.1.2, 1.1.1 and none of them work, I just get the same error, I then tried building pandas in the following fashion:
!python setup.py build_ext --inplace --force
And I still get the same error
Just for reference
I did some digging and it looks like pandas changed their api, which results in the error mentioned. I modified the source code and included the right imports which are in pyfinance/utils.py:
In line 77 changed from:
try:
from pandas.tseries.frequencies import FreqGroup, get_freq_code
except ImportError: # 0.24+, or somewhere around then
from pandas._libs.tslibs.frequencies import FreqGroup, get_freq_code
to
try:
from pandas.tseries.frequencies import FreqGroup, get_freq_code
except ImportError:
from pandas._libs.tslibs.dtypes import FreqGroup
from pandas.tests.tslibs.test_period_asfreq import get_freq_code
I created a pull request here if you're facing the same problem, you may clone and install my fork
Make sure you have the right version of pyfinance. Installing 0.1.3 solved my issue.
https://pypi.org/project/pyfinance/0.1.3/
I have got the following traceback error when importing pandas. I have installed all packages using anaconda3 distribution and also verified everything seems alright. When I use conda search numpy on command prompt also returns the installed packages. But if I try to import pandas as pd it throws an error.(numpy: No module named 'logging.handlers'; 'logging' is not a package) Need some guidance here.
Traceback (most recent call last):
File "1.py", line 1, in <module>
import pandas as pd
File "E:\Anaconda3\envs\venv\lib\site-packages\pandas\__init__.py", line 17, in <module>
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy: No module named 'logging.handlers'; 'logging' is not a package
I have a logging.py file on my project directory. After renaming the file also returns following error
Traceback (most recent call last):
File "1.py", line 1, in <module>
import pandas as pd
File "E:\Anaconda3\envs\venv\lib\site-packages\pandas\__init__.py", line 17, in <module>
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy: attempted relative import with no known parent package
After changing the entire project to a new directory resolves the issue.
i'm using python3 in my raspi. and i can't get sklearn to work or import pproperly in a code. i already tried to uninstall all numpy versions on my raspi. then only install numpy in python3 using: sudo apt-get install python3-numpy but i can't still get it to work. please help me everyone :(
thank you in advanced
this is the traceback of the error when importing sklearn
>>>
import sklearn
Traceback (most recent call last):
File "__init__.pxd", line 987, in numpy.import_array
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/sklearn/__init__.py", line 134, in <module>
from .base import clone
File "/usr/local/lib/python3.5/dist-packages/sklearn/base.py", line 13, in <module>
from .utils.fixes import signature
File "/usr/local/lib/python3.5/dist-packages/sklearn/utils/__init__.py", line 10, in <module>
from .murmurhash import murmurhash3_32
File "sklearn/utils/murmurhash.pyx", line 26, in init sklearn.utils.murmurhash
File "__init__.pxd", line 989, in numpy.import_array
ImportError: numpy.core.multiarray failed to import
I am new to Linux and do not know how to fix this error.
$ python googledrive/scripts/test.py
Traceback (most recent call last):
File "/home/michael/anaconda3/lib/python3.5/site-packages/pandas/compat/__init__.py", line 46, in <module>
import __builtin__ as builtins
ImportError: No module named '__builtin__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/michael/anaconda3/lib/python3.5/site-packages/pandas/__init__.py", line 7, in <module>
from pandas import hashtable, tslib, lib
File "pandas/tslib.pyx", line 53, in init pandas.tslib (pandas/tslib.c:102872)
File "/home/michael/anaconda3/lib/python3.5/site-packages/pandas/compat/__init__.py", line 59, in <module>
import http.client as httplib
File "/home/michael/anaconda3/lib/python3.5/http/client.py", line 71, in <module>
import email.parser
File "/home/michael/googledrive/scripts/email.py", line 4, in <module>
import pandas.io.data as web
File "/home/michael/anaconda3/lib/python3.5/site-packages/pandas/io/data.py", line 15, in <module>
from pandas.compat import(
ImportError: cannot import name 'bytes_to_str'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "googledrive/scripts/test.py", line 11, in <module>
main()
File "googledrive/scripts/test.py", line 2, in main
import pandas as pd
File "/home/michael/anaconda3/lib/python3.5/site-packages/pandas/__init__.py", line 13, in <module>
"extensions first.".format(module))
ImportError: C extension: 'bytes_to_str' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.
Python 3.5.0 :: Anaconda 2.4.0 (64-bit)
I tried conda install -f pandas and it still hasn't fixed my issued.
googledrive/scripts/test.py
def main():
import pandas as pd
import pandas.io.data as web
all_data = {}
all_data['fb'] = web.DataReader('fb','yahoo','1/1/2015', '11/24/2015')
print(all_data['fb'])
I do not know which directory I should run the below suggestion.
python setup.py build_ext --inplace
I don't have any problem running the code line by line in the terminal, but only when I try to run my script file.
>>> print(all_data['fb'])
Open High Low Close Volume \
Date
2015-01-02 78.580002 78.930000 77.699997 78.449997 18177500
2015-01-05 77.980003 79.250000 76.860001 77.190002 26452200
2015-01-06 77.230003 77.589996 75.360001 76.150002 27399300
Any help would be greatly appreciated.
I'm having a 'Cannot import name StringIO' error message when importing dateutil which tries to import StringIO but cannot find it. Here is complete trace:
(DEV)arbi#el-oued:~/Work/sentimentpy$ python core/main.py
Traceback (most recent call last):
File "core/main.py", line 7, in <module>
from io.reader import *
File "/home/arbi/Work/sentimentpy/core/io/reader.py", line 4, in <module>
from dateutil import parser
File "/home/arbi/DEV/local/lib/python2.7/site-packages/dateutil/parser.py", line 22, in <module>
from io import StringIO
ImportError: cannot import name StringIO
When I tried to use python3 to launch my program, i had this error:
(DEV)arbi#el-oued:~/Work/sentimentpy$ python3 core/main.py
Traceback (most recent call last):
File "core/main.py", line 1, in <module>
from analyzer.length import LengthAnalyzer
File "/home/arbi/Work/sentimentpy/core/analyzer/length.py", line 4, in <module>
from numpy
ImportError: No module named numpy
Why I'm having this? i've installed numpy in my virtualenv with: pip install numpy
You are masking the built-in io module because you have a package named io in your project:
Traceback (most recent call last):
File "core/main.py", line 7, in <module>
from io.reader import *
File "/home/arbi/Work/sentimentpy/core/io/reader.py", line 4, in <module>
The line from io import StringIO finds /home/arbi/Work/sentimentpy/core/io, not the built-in module.
Rename that package or move it into a new top-level package name that doesn't conflict.
Your second error is unrelated; you simply don't have numpy installed for Python 3.