【问题标题】:Unable to import pyPyrTools in python3无法在 python3 中导入 pyPyrTools
【发布时间】:2019-04-03 06:25:29
【问题描述】:

我已经从here 安装了pyPyrTools,使用: pip install pyPyrTools

它显示成功,但是在导入这个包时,给我一个错误: 回溯(最近一次调用最后一次): 文件“stdin”,第 1 行,在“模块”中 ModuleNotFoundError:没有名为“pyPyrTools”的模块

我如何使用这个包? 怎么了?

【问题讨论】:

  • 如果您使用的是venv(例如pycharm),您还需要将该模块添加到您的项目中,即使它已安装在您的系统中 --> 在File, settings, project interpreter 中,类似于其他 IDE。
  • 我没有使用 venv
  • 能否提供代码示例?

标签: python-3.x image-processing


【解决方案1】:

调试此类问题的方法是首先确定您使用的是哪个python 和哪个pip。然后,其次,查看您安装模块的位置以及 Python 查找不匹配项的位置。

所以,如果你使用命令python 来启动 Python,你会运行这个:

type python

如果你使用命令python3 来启动 Python,你会运行这个:

type python3

现在根据您的使用对pippip3 运行相同的命令:

type pip       # or "type pip3"

现在看看你运行的是什么版本的pythonpip

python -V      # or "python3 -V" if you use "python3"
pip -V         # or "pip3 -V" if you use "pip3"

您现在应该知道您正在使用哪些版本的工具。


现在看看pip(或pip3,如果你使用它)安装你的pyPyrTools

pip show pyPyrTools       # or "pip3 show pyPyrTools" if you use "pip3"

样本输出

Name: pyPyrTools
Version: 0.2.3
Summary: Python tools for multi-scale image processing, including Laplacian pyramids, Wavelets, and Steerable Pyramids
Home-page: https://github.com/LabForComputationalVision/pyPyrTools
Author: Eero Simoncelli, Rob Young, and William F. Broderick
Author-email: eero.simoncelli@nyu.edu
License: MIT
Location: /usr/local/lib/python3.7/site-packages
Requires: Pillow, numpy, matplotlib, scipy
Required-by:

特别重要的是倒数第三行的Location: 字段。


现在检查您的 Python 实际在哪里寻找模块:

python3 -c "import sys; print(sys.path)"     # or "python -c ..." if you use "python" rather than "python3"

样本输出

['', '/Users/mark/StackOverflow', '/Users/mark/OpenCV/lib/python3.7/site-packages', '/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/mark/Library/Python/3.7/lib/python/site-packages', '/usr/local/lib/python3.7/site-packages']

因此,我的答案上一部分中的Location:必须在此处列出,以便 Python 找到 pyPyrTools。如果不是,您要么使用与 python 不匹配的 pip 进行安装,要么未正确配置 PYTHONPATH。

如果您运行上述命令,请在您的问题下单击edit 并将输出粘贴到那里 - 不要在难以格式化和阅读的评论中。

【讨论】:

    猜你喜欢
    • 2018-09-19
    • 2022-01-03
    • 2017-02-15
    • 2018-12-05
    • 1970-01-01
    • 2021-05-31
    • 2021-02-11
    • 1970-01-01
    • 2015-08-17
    相关资源
    最近更新 更多