Importing pandas in windows - windows

I tried multiple methods with Anaconda and python both using version 3.6 and when I import pandas I'm getting the following error in my Windows machine
import pandas
File "D:\python3\lib\site-packages\pandas\__init__.py", line 22, in <module>
from pandas.compat.numpy import *
File "D:\python3\lib\site-packages\pandas\compat\__init__.py", line 59, in <module>
import http.client as httplib
File "D:\python3\lib\http\client.py", line 71, in <module>
import email.parser
File "D:\email.py", line 5, in <module>
import pandas.io.sql as psql
File "D:\python3\lib\site-packages\pandas\io\sql.py", line 14, in <module>
import pandas.lib as lib
File "pandas\lib.pyx", line 1, in init pandas.lib (pandas\lib.c:90879)
File "pandas\tslib.pyx", line 59, in init pandas.tslib (pandas\tslib.c:115313)
ImportError: cannot import name is_platform_windows
It seems to be environment related but I can't find anything related to this issue when I google this.

Looks like it was picking anything python script in my folder called email.py and that's causing the issue.

Related

I keep getting ModuleNotFoundError: No module named 'Crypto' but i have pycryptodome installed

I am using web3.py in my app, and things were working smoothly until I received this error.
Traceback (most recent call last):
File "run.py", line 1, in <module>
from api import app
File "C:\Users\Ty Cooper\Desktop\Coding\Projects\streamline\server\api\__init__.py", line 8, in <module>
from web3 import Web3
File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\web3\__init__.py", line 7, in <module>
from eth_account import Account # noqa: E402
File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\eth_account\__init__.py", line 1, in <module>
from eth_account.account import Account # noqa: F401
File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\eth_account\account.py", line 10, in <module>
from eth_keyfile import (
File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\eth_keyfile\__init__.py", line 7, in <module>
from eth_keyfile.keyfile import ( # noqa: F401
File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\eth_keyfile\keyfile.py", line 5, in <module>
from Crypto import Random
ModuleNotFoundError: No module named 'Crypto'
I have looked online to install pycryptodome and I have tried that and it is installed, but for some reason this error persist to populate.
I have found the issue. It was a naming error! I went to the site packages in
File "C:\Users\Ty Cooper\AppData\Local\Programs\Python\Python37\lib\site-packages\eth_keyfile\keyfile.py", line 5, in <module>
from Crypto import Random
and I just capitalize all of the folder names.

Error importing pandas through the bash envrionment

I've attempted to resolve this with answers to similar issues in the forum but was unsuccessful. Any help would be much appreciated as I've been stuck for a while.
I have downloaded Python through the Anaconda distribution.
When I attempt to import pandas by running a script (forum.py) in GITBASH I get the following error:
$ python forum.py
Traceback (most recent call last): File "forum.py", line 1, in
import pandas as pd File "C:\Users\jimen\Anaconda3\lib\site-packages\pandas__init__.py", line
42, in
from pandas.core.api import * File "C:\Users\jimen\Anaconda3\lib\site-packages\pandas\core\api.py", line
10, in
from pandas.core.groupby import Grouper File "C:\Users\jimen\Anaconda3\lib\site-packages\pandas\core\groupby.py",
line 50, in
from pandas.core.frame import DataFrame File "C:\Users\jimen\Anaconda3\lib\site-packages\pandas\core\frame.py",
line 77, in
from pandas.core.series import Series File "C:\Users\jimen\Anaconda3\lib\site-packages\pandas\core\series.py",
line 81, in
import pandas.plotting._core as gfx File "C:\Users\jimen\Anaconda3\lib\site-packages\pandas\plotting__init__.py",
line 15, in
from pandas.plotting._converter import \ File "C:\Users\jimen\Anaconda3\lib\site-packages\pandas\plotting_converter.py",
line 8, in
import matplotlib.units as units File "C:\Users\jimen\Anaconda3\lib\site-packages\matplotlib__init__.py",
line 1111, in
rcParamsOrig = RcParams(rcParams.copy()) File "C:\Users\jimen\Anaconda3\lib\site-packages\matplotlib__init__.py",
line 891, in getitem
from matplotlib import pyplot as plt File "C:\Users\jimen\Anaconda3\lib\site-packages\matplotlib\pyplot.py",
line 32, in
import matplotlib.colorbar File "C:\Users\jimen\Anaconda3\lib\site-packages\matplotlib\colorbar.py",
line 28, in
import matplotlib.artist as martist AttributeError: module 'matplotlib' has no attribute 'artist'
I'm not sure what to do and how to resolve this so any help would be much appreciated.
Thanks !

Error starting the Jupyter notebook on Windows

When I write jupyter notebookon my on command prompt, I get an error on cmd while running jupyter. I don't understand why this is happening again and again. Therefore, it blocks to open jupyter editor in the browser. I have added all environment variables as usual, but it's not working yet. Could you please help to solve this? Any kinds of suggestions are welcome.
H:\Research\NLP\NLP Task 1>jupyter notebook
Traceback (most recent call last):
File "C:\Users\Imran\Anaconda3\lib\site-packages\notebook\nbextensions.py", line 18, in <module>
from urllib.request import urlretrieve
File "C:\Users\Imran\AppData\Local\Programs\Python\Python36-32\Lib\urllib\request.py", line 88, in <module>
import http.client
File "C:\Users\Imran\AppData\Local\Programs\Python\Python36-32\Lib\http\client.py", line 71, in <module>
import email.parser
File "C:\Users\Imran\AppData\Local\Programs\Python\Python36-32\Lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "C:\Users\Imran\AppData\Local\Programs\Python\Python36-32\Lib\email\feedparser.py", line 27, in <module>
from email._policybase import compat32
File "C:\Users\Imran\AppData\Local\Programs\Python\Python36-32\Lib\email\_policybase.py", line 9, in <module>
from email.utils import _has_surrogates
File "C:\Users\Imran\AppData\Local\Programs\Python\Python36-32\Lib\email\utils.py", line 29, in <module>
import socket
File "C:\Users\Imran\AppData\Local\Programs\Python\Python36-32\Lib\socket.py", line 49, in <module>
import _socket
ImportError: DLL load failed: %1 is not a valid Win32 application.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Imran\Anaconda3\Scripts\jupyter-notebook-script.py", line 6, in <module>
from notebook.notebookapp import main
File "C:\Users\Imran\Anaconda3\lib\site-packages\notebook\__init__.py", line 25, in <module>
from .nbextensions import install_nbextension
File "C:\Users\Imran\Anaconda3\lib\site-packages\notebook\nbextensions.py", line 20, in <module>
from urlparse import urlparse
ModuleNotFoundError: No module named 'urlparse'
I uninstall python and anaconda. Then i reinstall it again. And it works again.

ImportError: No module named 'ruamel' running Anaconda

I am using MacOS X 10.11.2 and I want to install Anaconda 3, so that I downloaded the Anaconda3-4.3.0-MacOSX-x86_64.pkg from here. After I installed, I tried runnging this but I got the error like the following.
S0106602ad06e3352:bin jouk$ conda
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/conda/common/configuration.py", line 38, in <module>
from ruamel_yaml.comments import CommentedSeq, CommentedMap
ImportError: No module named 'ruamel_yaml'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/bin/conda", line 7, in <module>
from conda.cli.main import main
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/conda/cli/__init__.py", line 8, in <module>
from .main import main # NOQA
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/conda/cli/main.py", line 46, in <module>
from ..base.context import context
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/conda/base/context.py", line 18, in <module>
from ..common.configuration import (Configuration, MapParameter, PrimitiveParameter,
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/conda/common/configuration.py", line 40, in <module>
from ruamel.yaml.comments import CommentedSeq, CommentedMap # pragma: no cover
ImportError: No module named 'ruamel'
S0106602ad06e3352:bin jouk$
I tried solving this error with this workaround (here). But in this case is for the case in which I installed Anaconda twice to two places in local. But, I didn't do that. What is my problem?

running package throws ImportError: No module named image

Using cx_freeze under ubuntu 12.04. The generation of the package is
done without any errors but when I try to run the package as a
standalone, I get the following error:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/cx_Freeze/initscripts /Console.py",
line 27, in <module>
exec code in m.__dict__
m m File "Setup_cx_freeze.py", line 3, in <module>
File "/usr/local/lib/python2.7/dist-packages/cx_Freeze/__init__.py",
line 4, in <module>
from cx_Freeze.dist import *
File "/usr/local/lib/python2.7/dist-packages/cx_Freeze/dist.py",
line 3, in <module>
import distutils.command.install
File "/usr/lib/python2.7/distutils/command/install.py", line 21, in <module>
from site import USER_BASE
File "/usr/lib/python2.7/site.py", line 562, in <module>
main()
File "/usr/lib/python2.7/site.py", line 540, in main
abs__file__()
File "/usr/lib/python2.7/site.py", line 100, in abs__file__
m.__file__ = os.path.abspath(m.__file__)
File "/usr/lib/python2.7/email/__init__.py", line 79, in __getattr__
__import__(self.__name__)
ImportError: No module named image
I think what to focus on is the last sentence. "ImportError: No module named image."
The application runs without any problems in pure python environment
So why do I get the Error when running it as a "freeze" package? The
fault is somehow introduced when generating the freeze-package.
I ended up fixing this by explicitly including the package "email.mime" in the setup.py script build exe options.
Missing 'image' is just first part of the problem. Try to add this to your code:
from email.mime.image import MIMEImage
from email.mime.audio import MIMEAudio
from email.mime.message import MIMEMessage
This resolved problems with 'image', 'audio' and 'message'.
Resolved this by installing Python Imaging Library: http://www.pythonware.com/products/pil/
1) python setup.py build
2) sudo python setup.py install

Resources