[Python] Error when installing mplot3d in python for 3d plotting

Discussão em 'Python' iniciado por Stack, Julho 6, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to build a 3d surface plot in python. From what I've read, this is the standard package:

    from mpl_toolkits.mplot3d import Axes3D

    However, I receive the following Error:

    ImportError: No module named mpl_toolkits.mplot3d

    This is the error message I receive when trying to install the package:

    Myname-MacBook-Pro:ex1 myname$ sudo pip install --upgrade matplotlib
    The directory '/Users/ryansullivan/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
    The directory '/Users/ryansullivan/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
    Collecting matplotlib
    Downloading matplotlib-2.0.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (12.8MB)
    100% |████████████████████████████████| 12.8MB 101kB/s
    Collecting pyparsing!=2.0.0,!=2.0.4,!=2.1.2,!=2.1.6,>=1.5.6 (from matplotlib)
    Downloading pyparsing-2.1.10-py2.py3-none-any.whl (56kB)
    100% |████████████████████████████████| 61kB 4.6MB/s
    Collecting numpy>=1.7.1 (from matplotlib)
    Downloading numpy-1.12.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (4.4MB)
    100% |████████████████████████████████| 4.4MB 289kB/s
    Collecting functools32 (from matplotlib)
    Downloading functools32-3.2.3-2.zip
    Collecting pytz (from matplotlib)
    Downloading pytz-2016.10-py2.py3-none-any.whl (483kB)
    100% |████████████████████████████████| 491kB 1.4MB/s
    Collecting six>=1.10 (from matplotlib)
    Downloading six-1.10.0-py2.py3-none-any.whl
    Collecting cycler>=0.10 (from matplotlib)
    Downloading cycler-0.10.0-py2.py3-none-any.whl
    Collecting subprocess32 (from matplotlib)
    Downloading subprocess32-3.2.7.tar.gz (54kB)
    100% |████████████████████████████████| 61kB 2.7MB/s
    Collecting python-dateutil (from matplotlib)
    Downloading python_dateutil-2.6.0-py2.py3-none-any.whl (194kB)
    100% |████████████████████████████████| 194kB 2.2MB/s
    Installing collected packages: pyparsing, numpy, functools32, pytz, six, cycler, subprocess32, python-dateutil, matplotlib
    Found existing installation: pyparsing 2.0.1
    DEPRECATION: Uninstalling a distutils installed project (pyparsing) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling pyparsing-2.0.1:
    Exception:
    Traceback (most recent call last):
    File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
    File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
    File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 778, in install
    requirement.uninstall(auto_confirm=True)
    File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 754, in uninstall
    paths_to_remove.remove(auto_confirm)
    File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
    File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
    copy2(src, real_dst)
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
    copystat(src, dst)
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
    os.chflags(dst, st.st_flags)
    OSError: [Errno 1] Operation not permitted: '/tmp/pip-YwsZp1-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pyparsing-2.0.1-py2.7.egg-info'


    Any thoughts on what I'm doing wrong or how to avoid this error so that I can install mplot3d?

    Many thanks.

    Continue reading...

Compartilhe esta Página