0

我已经成功安装了 yappi,但是在同一个 shell 中导入 yappi 时仍然出现 ModuleNotFoundError:

((python) ) soumeng78@linux-16 $ pipenv install  git+https://github.com/sumerc/yappi#egg=yappi
Installing git+https://github.com/sumerc/yappi#egg=yappi...
Adding yappi to Pipfile's [packages]...
✔ Installation Succeeded
Pipfile.lock (db4242) out of date, updating to (b482eb)...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
✔ Success!
Updated Pipfile.lock (b482eb)!
Installing dependencies from Pipfile.lock (b482eb)...
  ðŸ   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/0 — 00:00:00

((python) ) soumeng78@linux-16 $ python
Python 3.9.6 (default, Jan  4 2022, 00:31:29)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import yappi

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<stdin> 1 <module>
1

ModuleNotFoundError:
No module named 'yappi'

知道如何使它工作吗?我想使用 yappi 来分析一个函数。

4

1 回答 1

0

删除旧环境并重新创建环境解决了这个问题。pipenv 似乎有些问题。

当我在 Windows 上的 conda 虚拟环境中尝试相同的 pip 安装时,我遇到了以下问题 - 包似乎有些问题:

Collecting yappi
  Using cached yappi-1.3.3.tar.gz (58 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: yappi
  Building wheel for yappi (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [9 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-3.8
      copying yappi\yappi.py -> build\lib.win-amd64-3.8
      running build_ext
      building '_yappi' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for yappi
  Running setup.py clean for yappi
Failed to build yappi
Installing collected packages: yappi
  Running setup.py install for yappi ... error
  error: subprocess-exited-with-error

  × Running setup.py install for yappi did not run successfully.
  │ exit code: 1
  ╰─> [11 lines of output]
      running install
      C:\Users\gsoumen\Miniconda3\envs\kubeflow-pipeline\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-3.8
      copying yappi\yappi.py -> build\lib.win-amd64-3.8
      running build_ext
      building '_yappi' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> yappi
于 2022-02-08T20:51:03.500 回答