Cannot import name StringIO when importing dateutil - python

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.

Related

cannot import 'ParserError' from 'dateutil.parser'

I am trying to import pandas in my code and it throws the following error.
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/gopika/.local/lib/python3.8/site-packages/pandas/__init__.py", line 48, in <module>
from pandas.core.api import (
File "/home/gopika/.local/lib/python3.8/site-packages/pandas/core/api.py", line 22, in <module>
from pandas.core.algorithms import (
File "/home/gopika/.local/lib/python3.8/site-packages/pandas/core/algorithms.py", line 39, in <module>
from pandas.core.dtypes.cast import (
File "/home/gopika/.local/lib/python3.8/site-packages/pandas/core/dtypes/cast.py", line 24, in <module>
from dateutil.parser import ParserError
ImportError: cannot import name 'ParserError' from 'dateutil.parser' (/usr/lib/python3/dist-packages/dateutil/parser/__init__.py)
I tried reinstalling python-dateutil but this doesn't solve the issue. I am not very sure what has changed in my enviroment but pandas was working normally and one day it suddenly start showing this error. It will be great if someone can help me with this. Thanks!
from dateutil.parser import ParserError
You defined, or installed, a dateutil module.
And it isn't this one:
https://pypi.org/project/python-dateutil 2.8.2
Rename / reinstall so the import succeeds.

library importing issues in pycharm

I'm doing a project on opencv python which is based on downloaded source code from the internet. When I run the code, this error occurs
C:\Users\Udara\AppData\Local\Programs\Python\Python38-32\python.exe C:/Users/Udara/Desktop/7777/people-counting-opencv/people_counter.py
Traceback (most recent call last):
File "C:/Users/Udara/Desktop/7777/people-counting-opencv/people_counter.py", line 13, in <module>
from pyimagesearch.centroidtracker import CentroidTracker
File "C:\Users\Udara\Desktop\7777\people-counting-opencv\pyimagesearch\centroidtracker.py", line 5, in <module>
import ordereddict
File "C:\Users\Udara\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ordereddict.py", line 23, in <module>
from UserDict import DictMixin
ModuleNotFoundError: No module named 'UserDict'

How to install a patch for numpy?

I am trying to install OpenBayes, but I get an error, that the numarray is not found.
>>> from OpenBayes import BNet
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\OpenBayes\__init__.py", line 7, in
<module>
from bayesnet import *
File "C:\Python27\lib\site-packages\OpenBayes\bayesnet.py", line 23, in
<module>
import numarray as na
ImportError: No module named numarray
>>>
As I got it, the numarray is now replaced by numpy.
There is a patch for Numpy here: https://github.com/willasaywhat/OpenBayes-Fork
But don't know how to install it.
I use Python 2.7 and have Win10/
Thanks for any info about this module!

xlwings - import error

Python 3.5 On Mac OS 10.12.2
When importing xlwings module i get a:
traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
import xlwings
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/xlwings/__init__.py", line 24, in <module>
from . import _xlmac as xlplatform
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/xlwings/_xlmac.py", line 10, in <module>
import aem
ImportError: No module named 'aem'
I have appscript installed already.
Any idea what i am missing here please?

Import Error: C extension (pandas; python; ubuntu)

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.

Categories

Resources