I am using Ubuntu system with python 2.7 and pandas version of 0.19.I have been trying to run a python file and this error keeps on showing up-
>>> import file.py as x
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "file.py", line 4, in <module>
import pandas as pd
File "/home/user/.local/lib/python2.7/site-packages/pandas/__init__.py", line 39, in <module>
from pandas.core.api import *
File "/home/user/.local/lib/python2.7/site-packages/pandas/core/api.py", line 20, in <module>
from pandas.core.reshape import (pivot_simple as pivot, get_dummies,
ImportError: cannot import name pivot_simple
Please help me in resolving the issue by telling the possible issues for this error and the way it can be removed.
Thanks!
instead of using 'files.py'
please try 'import files as x'
Related
I recently wanted to try coding with Pandas and Pygame on my Laptops VSCode, but got to some hard to solve problems that I managed to fix and now have come to a problem that I cant seem to solve.
On Jupyter Lab my Pandas and Pygame works perfectly, no problems or nothing and the basics work quite well. Importing Pandas or Pygame on Jupyter Lab gives me no errors even when I do actual code with it.
Now on VSCode on the other hand if I try to import them it gives me this error:
Pygame:
Traceback (most recent call last):
File "c:/Users/Joona/Pictures/pygametest.py", line 1, in <module>
import pygame as pyg
File "\\wsl$\Ubuntu-20.04\home\joonan\.local\lib\python3.8\site-packages\pygame\__init__.py", line 81, in <module>
from pygame.base import * # pylint: disable=wildcard-import; lgtm[py/polluting-import]
ModuleNotFoundError: No module named 'pygame.base'
Pandas:
Traceback (most recent call last):
import pandas as pd
File "\\wsl$\Ubuntu-20.04\home\joonan\.local\lib\python3.8\site-packages\pandas\__init__.py", line 22, in <module>
from pandas.compat import (
File "\\wsl$\Ubuntu-20.04\home\joonan\.local\lib\python3.8\site-packages\pandas\compat\__init__.py", line 15, in <module>
from pandas.compat.numpy import (
File "\\wsl$\Ubuntu-20.04\home\joonan\.local\lib\python3.8\site-packages\pandas\compat\numpy\__init__.py", line 7, in <module>
from pandas.util.version import Version
File "\\wsl$\Ubuntu-20.04\home\joonan\.local\lib\python3.8\site-packages\pandas\util\__init__.py", line 1, in <module>
from pandas.util._decorators import ( # noqa
File "\\wsl$\Ubuntu-20.04\home\joonan\.local\lib\python3.8\site-packages\pandas\util\_decorators.py", line 14, in <module>
from pandas._libs.properties import cache_readonly # noqa
File "\\wsl$\Ubuntu-20.04\home\joonan\.local\lib\python3.8\site-packages\pandas\_libs\__init__.py", line 13, in <module>
from pandas._libs.interval import Interval
ModuleNotFoundError: No module named 'pandas._libs.interval'
Other threads that I found say that reinstalling Pandas and Pygame works, but it did not work for me.
For
Are you using the same environment in the Jupyter notebook and python file?
I am trying to use the "statsmodels" package. When I try to import the package using this command:
import statsmodels
it works perfectly but when I tried to run the following comand in Python 2:
from statsmodels.distributions.empirical_distribution import ECDF
I will get the following error:
Traceback (most recent call last):
File "circleseq/circleseq.py", line 16, in <module>
import findCleavageSites
File "/mnt/data/users/S.Sie/circleseq/circleseq-master/circleseq/findCleavageSites.py", line 8, in <module>
from statsmodels.distributions.empirical_distribution import ECDF
File "/usr/lib64/python2.7/site-packages/statsmodels/distributions/__init__.py", line 1, in <module>
from statsmodels.tools._testing import PytestTester
File "/usr/lib64/python2.7/site-packages/statsmodels/tools/__init__.py", line 1, in <module>
from .tools import add_constant, categorical
File "/usr/lib64/python2.7/site-packages/statsmodels/tools/tools.py", line 8, in <module>
from statsmodels.compat.python import lzip, lmap
File "/usr/lib64/python2.7/site-packages/statsmodels/compat/__init__.py", line 1, in <module>
from statsmodels.tools._testing import PytestTester
File "/usr/lib64/python2.7/site-packages/statsmodels/tools/_testing.py", line 11, in <module>
from statsmodels.compat.pandas import assert_equal
File "/usr/lib64/python2.7/site-packages/statsmodels/compat/pandas.py", line 4, in <module>
import numpy as np
File "/usr/lib64/python2.7/site-packages/statsmodels/compat/numpy.py", line 46, in <module>
NP_LT_114 = LooseVersion(np.__version__) < LooseVersion('1.14')
AttributeError: 'module' object has no attribute '__version__'
I have to work with Python 2 since the tool I am using is in Python 2. How I can fix the issue?
Since you only work on Python 2, is it possible to rollback statsmodels where it was compatible to Python 2? You may lost some features, but you can check yourself if the older version is enough to fill in your requirements.
To rollback to an older version of a package, you can add the -I flag to your pip install.
pip install -I <package>==<version>
I am trying to plot with geopandas with this [tutorial][1]. However, whenever I run this: I find following errors:
Traceback (most recent call last):
File "/home/mahin/PycharmProjects/ProfessorEick-20191013T041703Z-001/ProfessorEick/KernelDensity2D/GeoPandasPlot.py", line 2, in <module>
import geoplot
File "/home/mahin/miniconda3/lib/python3.7/site-packages/geoplot/__init__.py", line 1, in <module>
from .geoplot import (
File "/home/mahin/miniconda3/lib/python3.7/site-packages/geoplot/geoplot.py", line 17, in <module>
import contextily as ctx
File "/home/mahin/miniconda3/lib/python3.7/site-packages/contextily/__init__.py", line 7, in <module>
from .place import Place, plot_map
File "/home/mahin/miniconda3/lib/python3.7/site-packages/contextily/place.py", line 6, in <module>
from .tile import howmany, bounds2raster, bounds2img, _sm2ll, _calculate_zoom
File "/home/mahin/miniconda3/lib/python3.7/site-packages/contextily/tile.py", line 20, in <module>
from rasterio.io import MemoryFile
ModuleNotFoundError: No module named 'rasterio.io'
I have tried installing rasterio using conda from the following link and also using the following instructions. However, the problem still exists. Anybody knows what could be the reason? My operating system is Ubuntu 18.06, I am running the code using pyccharm and my python version is 3.7.
So when I try to launch tensorboard I got this error :
Traceback (most recent call last):
File "/usr/local/bin/tensorboard", line 7, in <module>
from tensorflow.tensorboard.tensorboard import main
File "/usr/local/lib/python2.7/dist-packages/tensorflow/tensorboard/tensorboard.py", line 34, in <module>
from tensorflow.tensorboard.backend import server
File "/usr/local/lib/python2.7/dist-packages/tensorflow/tensorboard/backend/server.py", line 38, in <module>
from tensorflow.tensorboard.plugins.projector import plugin as projector_plugin
File "/usr/local/lib/python2.7/dist-packages/tensorflow/tensorboard/plugins/projector/plugin.py", line 27, in <module>
from tensorflow.contrib.tensorboard.plugins.projector import PROJECTOR_FILENAME
ImportError: cannot import name PROJECTOR_FILENAME
What's wrong ?
I've got this error when I've used following command to launch TB:
python -m tensorflow.tensorboard
When I've used another one it went ok:
tensorboard --logdir=path/to/log-directory
I have the most updated numpy, httplib2, pytz, Cython, python-dateutil & numexpr
And newest pandas build
But I'm flummoxed! The following code gives the following rather cryptic error. What is it trying to tell me?
import pandas
print "ok pandas"
error:
Traceback (most recent call last):
File "sank.py", line 1, in <module>
import pandas
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.14.1-py2.7-macosx-10.6-intel.egg/pandas/__init__.py", line 45, in <module>
from pandas.io.api import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.14.1-py2.7-macosx-10.6-intel.egg/pandas/io/api.py", line 15, in <module>
from pandas.io.gbq import read_gbq
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.14.1-py2.7-macosx-10.6-intel.egg/pandas/io/gbq.py", line 59, in <module>
import httplib2
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/httplib2-0.9-py2.7.egg/httplib2/__init__.py", line 1070, in <module>
from google.appengine.api import apiproxy_stub_map
File "/Users/maggielee/Documents/pythons/google.py", line 32, in <module>
GET / HTTP/1.0
NameError: name 'GET' is not defined
Solution by furas and OP.
I had an old file called google.py. Just renamed/deleted it and problem was solved.
Probably python uses this file when it imports from google.appengine.api.