【错误记录】Mac 中 IntelliJ IDEA 运行 Python 程序报错 ( No module named ‘numpy‘ )

简介: 【错误记录】Mac 中 IntelliJ IDEA 运行 Python 程序报错 ( No module named ‘numpy‘ )

文章目录

一、报错信息

二、解决方案





一、报错信息


编译时 , 报错如下信息 :


No module named ‘numpy‘



image.png





二、解决方案


image.png

image.png



pip install numpy


Try to run this command from the system terminal. 
Make sure that you use the correct version of 'pip' installed for your Python interpreter located at '/usr/local/bin/python3'.


Collecting numpy
  Using cached numpy-1.21.2.zip (10.3 MB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
Building wheels for collected packages: numpy
  Building wheel for numpy (PEP 517): started
  Building wheel for numpy (PEP 517): finished with status 'error'
Failed to build numpy
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python3 /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /var/folders/62/vmczqsnn1pq23nd3m8l20tgm0000gn/T/tmp1nsvz_z3
       cwd: /private/var/folders/62/vmczqsnn1pq23nd3m8l20tgm0000gn/T/pip-install-9_bhqerr/numpy_280faa88bab24eab97533beae7f5be03
  Complete output (152 lines):
  setup.py:63: RuntimeWarning: NumPy 1.21.2 may not yet support Python 3.10.
    warnings.warn(
  Running from numpy source directory.
  Cythonizing sources
  Processing numpy/random/_bounded_integers.pxd.in
  Processing numpy/random/_philox.pyx
  /private/var/folders/62/vmczqsnn1pq23nd3m8l20tgm0000gn/T/pip-install-9_bhqerr/numpy_280faa88bab24eab97533beae7f5be03/tools/cythonize.py:69: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
    from distutils.version import LooseVersion
  Processing numpy/random/_bounded_integers.pyx.in
  Processing numpy/random/_sfc64.pyx
  Processing numpy/random/_mt19937.pyx
  Processing numpy/random/bit_generator.pyx
  Processing numpy/random/mtrand.pyx
  Processing numpy/random/_generator.pyx
  Processing numpy/random/_pcg64.pyx
  Processing numpy/random/_common.pyx
  blas_opt_info:
  blas_mkl_info:
  customize UnixCCompiler
    libraries mkl_rt not found in ['/Library/Frameworks/Python.framework/Versions/3.10/lib', '/usr/local/lib', '/usr/lib']
    NOT AVAILABLE
  blis_info:
    libraries blis not found in ['/Library/Frameworks/Python.framework/Versions/3.10/lib', '/usr/local/lib', '/usr/lib']
    NOT AVAILABLE
  openblas_info:
    libraries openblas not found in ['/Library/Frameworks/Python.framework/Versions/3.10/lib', '/usr/local/lib', '/usr/lib']
    NOT AVAILABLE
  accelerate_info:
    libraries accelerate not found in ['/Library/Frameworks/Python.framework/Versions/3.10/lib', '/usr/local/lib', '/usr/lib']
  Library accelerate was not found. Ignoring
    libraries veclib not found in ['/Library/Frameworks/Python.framework/Versions/3.10/lib', '/usr/local/lib', '/usr/lib']
  Library veclib was not found. Ignoring
    FOUND:
      extra_compile_args = ['-msse3', '-I/System/Library/Frameworks/vecLib.framework/Headers']
      extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
      define_macros = [('NO_ATLAS_INFO', 3), ('HAVE_CBLAS', None)]
    FOUND:
      extra_compile_args = ['-msse3', '-I/System/Library/Frameworks/vecLib.framework/Headers']
      extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
      define_macros = [('NO_ATLAS_INFO', 3), ('HAVE_CBLAS', None)]
  non-existing path in 'numpy/distutils': 'site.cfg'
  lapack_opt_info:
  lapack_mkl_info:
    libraries mkl_rt not found in ['/Library/Frameworks/Python.framework/Versions/3.10/lib', '/usr/local/lib', '/usr/lib']
    NOT AVAILABLE
  openblas_lapack_info:
    libraries openblas not found in ['/Library/Frameworks/Python.framework/Versions/3.10/lib', '/usr/local/lib', '/usr/lib']
    NOT AVAILABLE
  openblas_clapack_info:
    libraries openblas,lapack not found in ['/Library/Frameworks/Python.framework/Versions/3.10/lib', '/usr/local/lib', '/usr/lib']
    NOT AVAILABLE
  flame_info:
    libraries flame not found in ['/Library/Frameworks/Python.framework/Versions/3.10/lib', '/usr/local/lib', '/usr/lib']
    NOT AVAILABLE
    FOUND:
      extra_compile_args = ['-msse3', '-I/System/Library/Frameworks/vecLib.framework/Headers']
      extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
      define_macros = [('NO_ATLAS_INFO', 3), ('HAVE_CBLAS', None)]
  Warning: attempted relative import with no known parent package
  /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/distutils/dist.py:274: UserWarning: Unknown distribution option: 'define_macros'
    warnings.warn(msg)
  running bdist_wheel
  running build
  running config_cc
  unifing config_cc, config, build_clib, build_ext, build commands --compiler options
  running config_fc
  unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
  running build_src
  build_src
  building py_modules sources
  creating build
  creating build/src.macosx-10.9-universal2-3.10
  creating build/src.macosx-10.9-universal2-3.10/numpy
  creating build/src.macosx-10.9-universal2-3.10/numpy/distutils
  building library "npymath" sources
  Could not locate executable gfortran
  Could not locate executable f95
  Could not locate executable f90
  Could not locate executable f77
  Could not locate executable xlf90
  Could not locate executable xlf
  Could not locate executable ifort
  Could not locate executable ifc
  Could not locate executable g77
  Could not locate executable g95
  Could not locate executable pgfortran
  don't know how to compile Fortran code on platform 'posix'
  xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
  Traceback (most recent call last):
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 349, in <module>
      main()
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 331, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 248, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
    File "/private/var/folders/62/vmczqsnn1pq23nd3m8l20tgm0000gn/T/pip-build-env-r0ly8_th/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 211, in build_wheel
      return self._build_with_temp_dir(['bdist_wheel'], '.whl',
    File "/private/var/folders/62/vmczqsnn1pq23nd3m8l20tgm0000gn/T/pip-build-env-r0ly8_th/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 197, in _build_with_temp_dir
      self.run_setup()
    File "/private/var/folders/62/vmczqsnn1pq23nd3m8l20tgm0000gn/T/pip-build-env-r0ly8_th/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 248, in run_setup
      super(_BuildMetaLegacyBackend,
    File "/private/var/folders/62/vmczqsnn1pq23nd3m8l20tgm0000gn/T/pip-build-env-r0ly8_th/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 142, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 448, in <module>
      setup_package()
    File "setup.py", line 440, in setup_package
      setup(**metadata)
    File "/private/var/folders/62/vmczqsnn1pq23nd3m8l20tgm0000gn/T/pip-install-9_bhqerr/numpy_280faa88bab24eab97533beae7f5be03/numpy/distutils/core.py", line 169, in setup
      return old_setup(**new_attr)
    File "/private/var/folders/62/vmczqsnn1pq23nd3m8l20tgm0000gn/T/pip-build-env-r0ly8_th/overlay/lib/python3.10/site-packages/setuptools/__init__.py", line 165, in setup
      return distutils.core.setup(**attrs)
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/private/var/folders/62/vmczqsnn1pq23nd3m8l20tgm0000gn/T/pip-build-env-r0ly8_th/overlay/lib/python3.10/site-packages/wheel/bdist_wheel.py", line 299, in run
      self.run_command('build')
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/private/var/folders/62/vmczqsnn1pq23nd3m8l20tgm0000gn/T/pip-install-9_bhqerr/numpy_280faa88bab24eab97533beae7f5be03/numpy/distutils/command/build.py", line 61, in run
      old_build.run(self)
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/private/var/folders/62/vmczqsnn1pq23nd3m8l20tgm0000gn/T/pip-install-9_bhqerr/numpy_280faa88bab24eab97533beae7f5be03/numpy/distutils/command/build_src.py", line 144, in run
      self.build_sources()
    File "/private/var/folders/62/vmczqsnn1pq23nd3m8l20tgm0000gn/T/pip-install-9_bhqerr/numpy_280faa88bab24eab97533beae7f5be03/numpy/distutils/command/build_src.py", line 155, in build_sources
      self.build_library_sources(*libname_info)
    File "/private/var/folders/62/vmczqsnn1pq23nd3m8l20tgm0000gn/T/pip-install-9_bhqerr/numpy_280faa88bab24eab97533beae7f5be03/numpy/distutils/command/build_src.py", line 288, in build_library_sources
      sources = self.generate_sources(sources, (lib_name, build_info))
    File "/private/var/folders/62/vmczqsnn1pq23nd3m8l20tgm0000gn/T/pip-install-9_bhqerr/numpy_280faa88bab24eab97533beae7f5be03/numpy/distutils/command/build_src.py", line 378, in generate_sources
      source = func(extension, build_dir)
    File "numpy/core/setup.py", line 666, in get_mathlib_info
      raise RuntimeError("Broken toolchain: cannot link a simple C program")
  RuntimeError: Broken toolchain: cannot link a simple C program
  ----------------------------------------
  ERROR: Failed building wheel for numpy
ERROR: Could not build wheels for numpy which use PEP 517 and cannot be installed directly
WARNING: You are using pip version 21.2.3; however, version 21.2.4 is available.
You should consider upgrading via the '/usr/local/bin/python3 -m pip install --upgrade pip' command.


这个错误大概是 numpy-1.21.2 与 Python3.10 版本不匹配导致 ;


目录
相关文章
|
2月前
|
Python
【10月更文挑战第10天】「Mac上学Python 19」小学奥数篇5 - 圆和矩形的面积计算
本篇将通过 Python 和 Cangjie 双语解决简单的几何问题:计算圆的面积和矩形的面积。通过这道题,学生将掌握如何使用公式解决几何问题,并学会用编程实现数学公式。
165 60
|
2月前
|
Python
【10月更文挑战第10天】「Mac上学Python 20」小学奥数篇6 - 一元一次方程求解
本篇将通过 Python 和 Cangjie 双语讲解如何求解一元一次方程。通过这道题,学生将掌握如何用编程实现方程求解,并体验基本的代数计算。
122 1
|
2月前
|
Python
【10月更文挑战第7天】「Mac上学Python 14」基础篇8 - 运算符详解
本篇将详细介绍Python中的运算符,包括数学运算、关系运算、逻辑运算、赋值运算和成员运算等内容。同时会说明运算符的优先级和运算顺序,帮助用户理解和掌握Python中的运算符使用规则。
41 3
【10月更文挑战第7天】「Mac上学Python 14」基础篇8 - 运算符详解
|
2月前
|
Python
【10月更文挑战第7天】「Mac上学Python 13」基础篇7 - 数据类型转换与NoneType详解
本篇将详细介绍Python中的常见数据类型转换方法以及 `NoneType` 的概念。包括如何在整数、浮点数、字符串等不同数据类型之间进行转换,并展示如何使用 `None` 进行初始赋值和处理特殊情况。通过本篇的学习,用户将深入理解如何处理不同类型的数据,并能够在代码中灵活使用 `None` 处理未赋值状态。
66 2
【10月更文挑战第7天】「Mac上学Python 13」基础篇7 - 数据类型转换与NoneType详解
|
2月前
|
Python
【10月更文挑战第7天】「Mac上学Python 15」小学奥数篇1 - 如何平分6个苹果和4个橘子
本篇将通过 Python 和 Cangjie 双语讲解一个简单的数学题:如何平分 N 个苹果和 M 个橘子。这道题旨在锻炼初学者的逻辑思维,并学会使用编程解决实际问题。
94 1
【10月更文挑战第7天】「Mac上学Python 15」小学奥数篇1 - 如何平分6个苹果和4个橘子
|
2月前
|
Python
【10月更文挑战第6天】「Mac上学Python 12」基础篇6 - 输入输出与格式化详解
本篇将详细介绍Python中的输入和输出函数,包括 `print()` 和 `input()` 函数的使用,涵盖格式化输出、类型转换及常见的字符串格式化方法。通过学习本篇,用户将掌握如何使用Python进行输入输出操作,并能灵活运用格式化输出处理数据。
63 1
【10月更文挑战第6天】「Mac上学Python 12」基础篇6 - 输入输出与格式化详解
|
2月前
|
Python
【10月更文挑战第6天】「Mac上学Python 11」基础篇5 - 字符串类型详解
本篇将详细介绍Python中的字符串类型及其常见操作,包括字符串的定义、转义字符的使用、字符串的连接与格式化、字符串的重复和切片、不可变性、编码与解码以及常用内置方法等。通过本篇学习,用户将掌握字符串的操作技巧,并能灵活处理文本数据。
59 1
【10月更文挑战第6天】「Mac上学Python 11」基础篇5 - 字符串类型详解
|
2月前
|
Java 索引 Python
【10月更文挑战第19天】「Mac上学Python 30」基础篇11 - 高级循环技巧与应用
本篇将介绍更深入的循环应用与优化方法,重点放在高级技巧和场景实践。我们将讲解enumerate()与zip()的妙用、迭代器与生成器、并发循环以及性能优化技巧。这些内容将帮助您编写更高效、结构更合理的代码。
70 5
|
2月前
|
数据安全/隐私保护 Python
【10月更文挑战第17天】「Mac上学Python 28」基础篇9 - 条件语句与逻辑判断
在Python中,条件语句和逻辑判断是控制程序执行流程的关键工具,帮助程序在不同条件下做出不同决策。通过本篇的学习,您将掌握单选、双分支、多选结构、单行条件表达式、条件嵌套、条件判断的类型和逻辑运算符的用法,从而更灵活地控制程序执行流程。
51 5
|
2月前
|
Python
【10月更文挑战第18天】「Mac上学Python 29」基础篇10 - 循环结构与迭代控制
在Python中,循环结构是控制程序执行的重要工具。通过学习本篇内容,您将掌握如何使用for循环和while循环来高效地处理重复任务,并了解break、continue和else的使用方式。同时,我们还会探索嵌套循环和典型应用场景中的实际应用。
43 2