When trying to run the following script:
import matplotlib as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
I exeperience the following error:
C:\Users\raja\PycharmProjects\Project_test\venv\Scripts\python.exe C:/Users/raja/.PyCharmCE2018.2/config/scratches/testing.py
Traceback (most recent call last):
File "C:/Users/raja/.PyCharmCE2018.2/config/scratches/testing.py", line 1, in <module>
import matplotlib as plt
File "C:\Users\raja\PycharmProjects\Project_test\venv\lib\site-packages\matplotlib\__init__.py", line 136, in <module>
import urllib.request
File "C:\Users\raja\AppData\Local\Programs\Python\Python37\lib\urllib\request.py", line 88, in <module>
import http.client
File "C:\Users\raja\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 71, in <module>
import email.parser
File "C:\Users\raja\AppData\Local\Programs\Python\Python37\lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "C:\Users\raja\AppData\Local\Programs\Python\Python37\lib\email\feedparser.py", line 27, in <module>
from email._policybase import compat32
File "C:\Users\raja\AppData\Local\Programs\Python\Python37\lib\email\_policybase.py", line 9, in <module>
from email.utils import _has_surrogates
File "C:\Users\raja\AppData\Local\Programs\Python\Python37\lib\email\utils.py", line 33, in <module>
from email._parseaddr import quote
File "C:\Users\raja\AppData\Local\Programs\Python\Python37\lib\email\_parseaddr.py", line 16, in <module>
import time, calendar
File "C:\Users\raja\.PyCharmCE2018.2\config\scratches\calendar.py", line 7, in <module>
import tkcalendar
ModuleNotFoundError: No module named 'tkcalendar'
Why? Does anybody know how to solve this issue?
I have fixed it. there was a different python program I named it as Calendar.py :(. I have deleted that file from "config/scratches/" and it has fixed the issue.
Also I have deleted the two versions of Tkcalendar installed
Related
Python refuses to import any module, including something as basic as numpy, and throws the same error for all of them.
I am working with Python 3.5.2 and Anaconda 4.2.0 (64-bit) with GCC 4.4.7 (Red Hat 4.4.7-1). I recently installed the following modules via pip:
packaging
appdirs
triangle
glumpy
See example feedback below.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/anaconda3/lib/python3.5/site-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/anaconda3/lib/python3.5/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/anaconda3/lib/python3.5/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/anaconda3/lib/python3.5/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/anaconda3/lib/python3.5/site-packages/numpy/core/__init__.py", line 33, in <module>
from . import _internal # for freeze programs
File "/anaconda3/lib/python3.5/site-packages/numpy/core/_internal.py", line 12, in <module>
from numpy.compat import asbytes, basestring
File "/anaconda3/lib/python3.5/site-packages/numpy/compat/__init__.py", line 13, in <module>
from . import _inspect
File "/anaconda3/lib/python3.5/site-packages/numpy/compat/_inspect.py", line 10, in <module>
import types
File "/anaconda3/lib/python3.5/types.py", line 166, in <module>
import functools as _functools
File "/anaconda3/lib/python3.5/functools.py", line 21, in <module>
from collections import namedtuple
File "/anaconda3/pkgs/vispy-0.4.0.106.gf8a69d0-np110py35_0/lib/python3.5/site-packages/vispy/visuals/collections/__init__.py", line 26, in <module>
from . path_collection import PathCollection # noqa
File "/anaconda3/pkgs/vispy-0.4.0.106.gf8a69d0-np110py35_0/lib/python3.5/site-packages/vispy/visuals/collections/path_collection.py", line 6, in <module>
from . raw_path_collection import RawPathCollection
File "/anaconda3/pkgs/vispy-0.4.0.106.gf8a69d0-np110py35_0/lib/python3.5/site-packages/vispy/visuals/collections/raw_path_collection.py", line 7, in <module>
from vispy import glsl
File "/anaconda3/lib/python3.5/site-packages/vispy/__init__.py", line 30, in <module>
from .util import config, set_log_level, keys, sys_info # noqa
File "/anaconda3/lib/python3.5/site-packages/vispy/util/__init__.py", line 9, in <module>
from .logs import logger, set_log_level, use_log_level # noqa
File "/anaconda3/lib/python3.5/site-packages/vispy/util/logs.py", line 6, in <module>
import logging
File "/anaconda3/lib/python3.5/logging/__init__.py", line 26, in <module>
import sys, os, time, io, traceback, warnings, weakref, collections
File "/anaconda3/lib/python3.5/traceback.py", line 5, in <module>
import linecache
File "/anaconda3/lib/python3.5/linecache.py", line 11, in <module>
import tokenize
File "/anaconda3/lib/python3.5/tokenize.py", line 98, in <module>
class TokenInfo(collections.namedtuple('TokenInfo', 'type string start end line')):
AttributeError: module 'collections' has no attribute 'namedtuple'
How do I fix this?
I've installed Anaconda 4.1.12 x64 on Windows and, when running python apps on command line, it imports packages as numpy just fine... unless I set the environment variable PYTHONPATH. I want to run Caffe on windows, and thus I need to put the Caffe binding on its path.
My test case is this small test.py file:
import numpy as np
print np
If I python test.py it on the command line, with PYTHONPATH not set, I get this:
<module 'numpy' from 'C:\Anaconda2\lib\site-packages\numpy\__init__.pyc'>
Seems fine. But if I set PYTHONPATH, the output is this:
Traceback (most recent call last):
File "test.py", line 1, in <module>
import numpy as np
File "C:\Anaconda2\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Anaconda2\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Anaconda2\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Anaconda2\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Anaconda2\lib\site-packages\numpy\core\__init__.py", line 58, in <module>
from numpy.testing.nosetester import _numpy_tester
File "C:\Anaconda2\lib\site-packages\numpy\testing\__init__.py", line 12, in <module>
from . import decorators as dec
File "C:\Anaconda2\lib\site-packages\numpy\testing\decorators.py", line 21, in <module>
from .utils import SkipTest
File "C:\Anaconda2\lib\site-packages\numpy\testing\utils.py", line 15, in <module>
from tempfile import mkdtemp, mkstemp
File "C:\Anaconda2\lib\tempfile.py", line 32, in <module>
import io as _io
File "C:\caffe-windows\python\caffe\io.py", line 2, in <module>
import skimage.io
File "C:\Anaconda2\lib\site-packages\skimage\__init__.py", line 157, in <module>
from .util.dtype import *
File "C:\Anaconda2\lib\site-packages\skimage\util\__init__.py", line 1, in <module>
from .dtype import (img_as_float, img_as_int, img_as_uint, img_as_ubyte,
File "C:\Anaconda2\lib\site-packages\skimage\util\dtype.py", line 8, in <module>
dtype_range = {np.bool_: (False, True),
AttributeError: 'module' object has no attribute 'bool_'
What am I missing?
Edit: adding feedback for #cco:
While trying to import skimage.io:
With PYTHONPATH not set:
<module 'skimage.io' from 'C:\Anaconda2\lib\site-packages\skimage\io\__init__.pyc'>
With PYTHONPATH set:
Traceback (most recent call last):
File "test2.py", line 1, in <module>
import skimage.io as ski
File "C:\Anaconda2\lib\site-packages\skimage\__init__.py", line 157, in <module>
from .util.dtype import *
File "C:\Anaconda2\lib\site-packages\skimage\util\__init__.py", line 1, in <module>
from .dtype import (img_as_float, img_as_int, img_as_uint, img_as_ubyte,
File "C:\Anaconda2\lib\site-packages\skimage\util\dtype.py", line 2, in <module>
import numpy as np
File "C:\Anaconda2\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Anaconda2\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Anaconda2\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Anaconda2\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Anaconda2\lib\site-packages\numpy\core\__init__.py", line 58, in <module>
from numpy.testing.nosetester import _numpy_tester
File "C:\Anaconda2\lib\site-packages\numpy\testing\__init__.py", line 12, in <module>
from . import decorators as dec
File "C:\Anaconda2\lib\site-packages\numpy\testing\decorators.py", line 21, in <module>
from .utils import SkipTest
File "C:\Anaconda2\lib\site-packages\numpy\testing\utils.py", line 15, in <module>
from tempfile import mkdtemp, mkstemp
File "C:\Anaconda2\lib\tempfile.py", line 32, in <module>
import io as _io
File "C:\caffe-windows\python\caffe\io.py", line 2, in <module>
import skimage.io
File "C:\Anaconda2\lib\site-packages\skimage\io\__init__.py", line 11, in <module>
from ._io import *
File "C:\Anaconda2\lib\site-packages\skimage\io\_io.py", line 1, in <module>
from io import BytesIO
ImportError: cannot import name BytesIO
When I run the line from skimage import io I get the following:
Traceback (most recent call last):
File "C:\Users\Dilshad\Desktop\project_7-8-2015\8_bands\Program_camera.py", line 16, in <module>
from Functions_8bands import *
File "C:\Users\Dilshad\Desktop\project_7-8-2015\8_bands\Functions_8bands.py", line 5, in <module>
from skimage import io
File "C:\Users\Dilshad\AppData\Local\Programs\Python\Python35\lib\site-packages\skimage\io\__init__.py", line 11, in <module>
from ._io import *
File "C:\Users\Dilshad\AppData\Local\Programs\Python\Python35\lib\site-packages\skimage\io\_io.py", line 8, in <module>
from ..color import rgb2grey
File "C:\Users\Dilshad\AppData\Local\Programs\Python\Python35\lib\site-packages\skimage\color\__init__.py", line 1, in <module>
from .colorconv import (convert_colorspace,
File "C:\Users\Dilshad\AppData\Local\Programs\Python\Python35\lib\site-packages\skimage\color\colorconv.py", line 58, in <module>
from scipy import linalg
File "C:\Users\Dilshad\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\linalg\__init__.py", line 172, in <module>
from .misc import *
File "C:\Users\Dilshad\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\linalg\misc.py", line 5, in <module>
from .blas import get_blas_funcs
File "C:\Users\Dilshad\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\linalg\blas.py", line 155, in <module>
from scipy.linalg import _fblas
ImportError: DLL load failed: The specified module could not be found.
I've searched through the site-package file and I see that io exists so I'm not really sure whats's missing.
Not sure why it worked but installing numpy +mkl instead of numpy vanilla from the unofficial binary site on UCI got around this for me.
I am struggling to get an ide working for python 2.7 with numpy, scipy, matplotlib and wxpython/PyQt installed. Running the ide spyder throws up the message "module 'object' has no attribute 'core'" for numpy. Same message occurs while "from numpy import *" on IDLE.
Here is the whole message. Please help. Thanks!
C:\Python27\Scripts>C:\Python27\python.exe "C:\Python27\Scripts\spyder"
Traceback (most recent call last):
File "C:\Python27\Scripts\spyder", line 2, in <module>
from spyderlib import spyder
File "C:\Python27\lib\site-packages\spyderlib\spyder.py", line 96, in <module>
from spyderlib.utils.environ import WinUserEnvDialog
File "C:\Python27\lib\site-packages\spyderlib\utils\environ.py", line 17, in <module>
from spyderlib.widgets.dicteditor import DictEditor
File "C:\Python27\lib\site-packages\spyderlib\widgets\dicteditor.py", line 31, in <module>
from spyderlib.config import get_icon, get_font
File "C:\Python27\lib\site-packages\spyderlib\config.py", line 27, in <module>
from spyderlib.utils import iofuncs, codeanalysis
File "C:\Python27\lib\site-packages\spyderlib\utils\iofuncs.py", line 61, in <module>
import numpy as np
File "C:\Users\User\AppData\Roaming\Python\Python27\site-packages\numpy\__init__.py", line 137, in <module>
import add_newdocs
File "C:\Users\User\AppData\Roaming\Python\Python27\site-packages\numpy\add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "C:\Users\User\AppData\Roaming\Python\Python27\site-packages\numpy\lib\__init__.py", line 13, in <module>
from polynomial import *
File "C:\Users\User\AppData\Roaming\Python\Python27\site-packages\numpy\lib\polynomial.py", line 11, in <module>
import numpy.core.numeric as NX
AttributeError: 'module' object has no attribute 'core'
I am trying to get matplotlib to work under Windows 7 (64-bit) using Python 2.7 and Eclipse with the PyDev plugin . I installed NumPy from http://www.lfd.uci.edu/~gohlke/pythonlibs/.
The problem is when I write the following code in Eclipse:
import matplotlib.pyplot as plt
plt.figure()
I get the following error:
Traceback (most recent call last):
File "C:\Users\davedove\Documents\eclipseWorkspace\python.graphExample\example.py", line 1, in <module>
import matplotlib.pyplot as plt
File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 104, in <module>
import os, re, shutil, subprocess, sys, warnings
File "C:\Python27\lib\shutil.py", line 12, in <module>
import collections
File "C:\Python27\Lib\site-packages\matplotlib\collections.py", line 12, in <module>
import numpy as np
File "C:\Python27\lib\site-packages\numpy\__init__.py", line 147, in <module>
import add_newdocs
File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 4, in <module>
from type_check import *
File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 40, in <module>
from numpy.testing import Tester
File "C:\Python27\lib\site-packages\numpy\testing\__init__.py", line 8, in <module>
from unittest import TestCase
File "C:\Python27\lib\unittest\__init__.py", line 58, in <module>
from .result import TestResult
File "C:\Python27\lib\unittest\result.py", line 9, in <module>
from . import util
File "C:\Python27\lib\unittest\util.py", line 2, in <module>
from collections import namedtuple, OrderedDict
ImportError: cannot import name namedtuple
Also with NumPy when I write the following code in Eclipse:
import numpy
add(array([-1.2, 1.2]), array([1,3]))
I get the following error:
Traceback (most recent call last):
File "C:\Users\davedove\Documents\eclipseWorkspace\python.graphExample\example.py", line 1, in <module>
import numpy
File "C:\Python27\lib\site-packages\numpy\__init__.py", line 147, in <module>
import add_newdocs
File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 4, in <module>
from type_check import *
File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 40, in <module>
from numpy.testing import Tester
File "C:\Python27\lib\site-packages\numpy\testing\__init__.py", line 8, in <module>
from unittest import TestCase
File "C:\Python27\lib\unittest\__init__.py", line 58, in <module>
from .result import TestResult
File "C:\Python27\lib\unittest\result.py", line 9, in <module>
from . import util
File "C:\Python27\lib\unittest\util.py", line 2, in <module>
from collections import namedtuple, OrderedDict
File "C:\Python27\Lib\site-packages\matplotlib\collections.py", line 13, in <module>
import numpy.ma as ma
File "C:\Python27\lib\site-packages\numpy\ma\__init__.py", line 44, in <module>
import core
File "C:\Python27\lib\site-packages\numpy\ma\core.py", line 73, in <module>
from numpy import ndarray, amax, amin, iscomplexobj, bool_
ImportError: cannot import name ndarray
From the command line both NumPy & matplotlib both run fine, I have added both matplotlib and NumPy from preferences -> pydev -> interpreter python. What could be the problem? Also what alternative could I use to create graphs using Python?
Works for me. Very probably you have added matplotlib and numpy directories to your PYTHONPATH, such that matplotlib.collections is imported instead of the collections module from the Python standard library. Try remove matplotlib and numpy directories from the PYTHONPATH in the Eclipse > PyDev > Python interpreter settings.
I was having the same issue, but follow the instructions at the bottom of the page and installed the SciPy SuperPack. Worked like a charm on Mountain Lion:
https://github.com/fonnesbeck/ScipySuperpack
After it installs numpy you can always just ctrl-C out of the other packages