简体   繁体   中英

import error but in the program init, can someone help me? (Python 2.7.14)

I have those errors when i'm trying to import the matplotlib. How can i fix this?

I have install matplotlib with the pip install matplotlib and this was a succes. But when i import the package i have this kind of error. i see it is in the init block but how can i fix this?

i have already tried the pip matplotlib upgrade but this keeps the same problem. i just have matplotlib uninstalled and back installed and it is the same problem.

My code:

import matplotlib.pyplot as plt

Error:

Traceback (most recent call last):
  File "C:\Python27\TEST.py", line 1, in <module>
    import matplotlib.pyplot as plt
  File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 26, in <module>
    from matplotlib.figure import Figure, figaspect
  File "C:\Python27\lib\site-packages\matplotlib\figure.py", line 24, in <module>
    import matplotlib.artist as martist
  File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 7, in <module>
    from transforms import Bbox, IdentityTransform, TransformedBbox, \
  File "C:\Python27\lib\site-packages\matplotlib\transforms.py", line 35, in <module>
    from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: DLL load failed: %1 is geen geldige Win32-toepassing

I have tried another code, that I found in the comments. But this generate my another error code.

Code :

import matplotlib as mpl
mpl.use('TkAgg')
import matplotlib.pyplot as plt

Error:

Traceback (most recent call last):
  File "C:\Python27\TEST.py", line 1, in <module>
    import matplotlib as mpl
  File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 1097, in <module>
    rcParams = rc_params()
  File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 933, in rc_params
    fname = matplotlib_fname()
  File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 781, in matplotlib_fname
    for fname in gen_candidates():
  File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 770, in gen_candidates
    yield os.path.join(six.moves.getcwd(), 'matplotlibrc')
AttributeError: '_MovedItems' object has no attribute 'getcwd'

Error Little test program

A "p" seems to be missing from "pyplot". You have pylot instead of pyplot in the import statement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM