【问题标题】:MacOS, Python: ModuleNotFoundError: No module named 'kiwisolver'MacOS,Python:ModuleNotFoundError:没有名为“kiwisolver”的模块
【发布时间】:2018-09-06 10:19:28
【问题描述】:

我尝试在 MacOS Sierra 上的 Atom 中导入 kiwisolver,但出现未找到错误:

输入:

import kiwisolver as kiwi

输出:

Traceback (most recent call last):
File "/Users/Kev/Documents/Uvic/Python/PHYS 321B/A6Q5&6_Coupled_Oscillators_Matrix.py", line 3, in <module>
import kiwisolver as kiwi
ModuleNotFoundError: No module named 'kiwisolver'

问题是已经安装好了:

w134-87-183-190:~ Kev$ sudo python -m pip install kiwisolver

The directory '/Users/Kev/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/Kev/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 kiwisolver
Downloading kiwisolver-1.0.1-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 (110kB)
100% |████████████████████████████████| 112kB 831kB/s 
Requirement already satisfied: setuptools in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from kiwisolver)
Installing collected packages: kiwisolver
Successfully installed kiwisolver-1.0.1

w134-87-183-190:~ Kev$ sudo python3 -m pip install kiwisolver

The directory '/Users/Kev/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/Kev/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.
Requirement already satisfied: kiwisolver in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from kiwisolver)

有人遇到过这个问题吗?我该如何解决这个问题?我需要它来运行 Matplotlib。

编辑:我使用的是 Python 3.6。

w134-87-183-190:~ Kev$ python -V
Python 2.7.10

w134-87-183-190:~ Kev$ python --version 
Python 2.7.10

w134-87-183-190:~ Kev$ python3 --version 
Python 3.6.4

在 atom 中,我的 config.cson 中有这个。所有三个路径都给出相同的错误:

runner:
    scopes:
      # python: "/usr/local/bin/python3"
      # python: "/Library/Frameworks/Python.framework/Versions/3.6/Python"
      python: "/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6"

【问题讨论】:

  • 你用的是python2还是3?
  • 我安装了我正在使用的 Python 3.6,尽管 MacOS 附带 Apple 提供的 2.7。
  • 你的环境用的是什么python?
  • Python 3.6(我认为),因为这是我给 Atom 的路径:“/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6”

标签: python macos atom-editor


【解决方案1】:

如果您使用的是 Mac,请尝试运行它,因为您可能会遇到一些权限问题:

pip3 install kiwisolver --user

【讨论】:

  • 它告诉我:Requirement already satisfied: kiwisolver in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from kiwisolver)
  • @Kevin 也许您已经为其他用户安装了它(例如,使用 sudo)?或者你已经安装在本地或者非标准的包目录下?
  • 我已经安装在:/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
【解决方案2】:

经过 3 个多小时的痛苦,结果证明解决方案非常简单。

卸载 Kiwisolver:

pip3 uninstall kiwisolver 

然后重新安装 Kiwisolver:

pip3 install kiwisolver

【讨论】:

    猜你喜欢
    • 2020-12-28
    • 2021-11-07
    • 1970-01-01
    • 2022-06-14
    • 1970-01-01
    • 2021-11-26
    • 2017-07-16
    • 2021-06-09
    • 2023-03-03
    相关资源
    最近更新 更多