CS技术大佬 2024-05-14 19:46 采纳率: 0%
浏览 28

pytest --version报错

pytest安装后使用pytest命令报错,各位人才给看看哪里有问题呀?
最新:问题已解决
原因:
pycharm中设置shell为cmd.exe,而cmd.exe中默认使用的是anaconda的解释器(也不清楚pytest的安装情况等,不咋用),而非我常用的单独的python解释器,所以报错
解决方法:
1.删除环境变量中Path里关于anaconda的信息
2.重启pycharm
3.在pycharm终端中执行pytest命令就可以执行了,注意pytest命令后需要写完整.py文件的路径
前提:
1.我电脑中有单独的python解释器,也有anaconda环境,二者都在环境变量path中配置了
2.一般我使用pycharm默认选的是单独的python解释器
3.我利用pycharm下载pytest后,单独的python解释器目录下已经有了pytest.py
4.在cmd中使用pytest --version报错,详细如下

pip show pytest执行可以看到pytest成功安装了
Name: pytest
Version: 7.4.4
Summary: pytest: simple powerful testing with Python
Home-page: https://docs.pytest.org/en/latest/
Author: Holger Krekel, Bruno Oliveira, Ronny Pfannschmidt, Floris Bruynooghe, Brianna Laugher, Florian Bruhin and others
Author-email: None
License: MIT
Location: f:\anaconda32020.02\lib\site-packages
Requires: importlib-metadata, pluggy, iniconfig, tomli, colorama, exceptiongroup, packaging
Required-by: pytest-remotedata, pytest-openfiles, pytest-filter-subpackage, pytest-doctestplus, pytest-cov, pytest-astropy, pytest-astropy-header, pytest-arraydiff
pytest --version命令执行后报错信息
f:\anaconda32020.02\lib\site-packages\numpy\__init__.py:140: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
  from . import _distributor_init
Traceback (most recent call last):
  File "f:\anaconda32020.02\lib\site-packages\numpy\core\__init__.py", line 24, in <module>
    from . import multiarray
  File "f:\anaconda32020.02\lib\site-packages\numpy\core\multiarray.py", line 14, in <module>
    from . import overrides
  File "f:\anaconda32020.02\lib\site-packages\numpy\core\overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ImportError: DLL load failed: 找不到指定的模块。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "f:\anaconda32020.02\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "f:\anaconda32020.02\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "F:\Anaconda32020.02\Scripts\pytest.exe\__main__.py", line 7, in <module>
    sys.exit(console_main())
  File "f:\anaconda32020.02\lib\site-packages\_pytest\config\__init__.py", line 192, in console_main
    code = main()
  File "f:\anaconda32020.02\lib\site-packages\_pytest\config\__init__.py", line 150, in main
    config = _prepareconfig(args, plugins)
  File "f:\anaconda32020.02\lib\site-packages\_pytest\config\__init__.py", line 332, in _prepareconfig
    pluginmanager=pluginmanager, args=args
  File "f:\anaconda32020.02\lib\site-packages\pluggy\hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "f:\anaconda32020.02\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "f:\anaconda32020.02\lib\site-packages\pluggy\manager.py", line 87, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "f:\anaconda32020.02\lib\site-packages\pluggy\callers.py", line 203, in _multicall
    gen.send(outcome)
  File "f:\anaconda32020.02\lib\site-packages\_pytest\helpconfig.py", line 104, in pytest_cmdline_parse
    config: Config = outcome.get_result()
  File "f:\anaconda32020.02\lib\site-packages\pluggy\callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "f:\anaconda32020.02\lib\site-packages\pluggy\callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "f:\anaconda32020.02\lib\site-packages\_pytest\config\__init__.py", line 1075, in pytest_cmdline_parse
    self.parse(args)
  File "f:\anaconda32020.02\lib\site-packages\_pytest\config\__init__.py", line 1425, in parse
    self._preparse(args, addopts=addopts)
  File "f:\anaconda32020.02\lib\site-packages\_pytest\config\__init__.py", line 1305, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "f:\anaconda32020.02\lib\site-packages\pluggy\manager.py", line 299, in load_setuptools_entrypoints
    plugin = ep.load()
  File "f:\anaconda32020.02\lib\site-packages\importlib_metadata\__init__.py", line 94, in load
    module = import_module(match.group('module'))
  File "f:\anaconda32020.02\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "f:\anaconda32020.02\lib\site-packages\_pytest\assertion\rewrite.py", line 186, in exec_module
    exec(co, module.__dict__)
  File "f:\anaconda32020.02\lib\site-packages\pytest_arraydiff\plugin.py", line 45, in <module>
    import numpy as np
  File "f:\anaconda32020.02\lib\site-packages\numpy\__init__.py", line 142, in <module>
    from . import core
  File "f:\anaconda32020.02\lib\site-packages\numpy\core\__init__.py", line 54, in <module>
    raise ImportError(msg)
ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
  1. Check that you expected to use Python3.7 from "f:\anaconda32020.02\python.exe",
     and that you have no directories in your PATH or PYTHONPATH that can
     interfere with the Python and numpy version "1.18.1" you're trying to use.
  2. If (1) looks fine, you can open a new issue at
     https://github.com/numpy/numpy/issues.  Please include details on:
     - how you installed Python
     - how you installed numpy
     - your operating system
     - whether or not you have multiple versions of Python installed
     - if you built from source, your compiler versions and ideally a build log

- If you're working with a numpy git repository, try `git clean -xdf`
  (removes all files not under version control) and rebuild numpy.

Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.

Original error was: DLL load failed: 找不到指定的模块。
  • 写回答

1条回答 默认 最新

  • svygh123 2024-05-14 21:21
    关注

    可以根据提示操作:
    Please install mkl-service package
    see http://github.com/IntelPython/mkl-service

    评论

报告相同问题?

问题事件

  • 修改了问题 5月14日
  • 修改了问题 5月14日
  • 创建了问题 5月14日

悬赏问题

  • ¥20 python忆阻器数字识别
  • ¥15 无法输出helloworld
  • ¥15 高通uboot 打印ubi init err 22
  • ¥20 PDF元数据中的XMP媒体管理属性
  • ¥15 R语言中lasso回归报错
  • ¥15 网站突然不能访问了,上午还好好的
  • ¥15 有没有dl可以帮弄”我去图书馆”秒选道具和积分
  • ¥15 semrush,SEO,内嵌网站,api
  • ¥15 Stata:为什么reghdfe后的因变量没有被发现识别啊
  • ¥15 振荡电路,ADS仿真