GVKun编程网logo

在 macOS BigSur 上使用 Python 3.9.1 安装 Numpy 1.19.5 时遇到问题(mac怎么在python安装numpy库)

3

在本文中,我们将为您详细介绍在macOSBigSur上使用Python3.9.1安装Numpy1.19.5时遇到问题的相关知识,并且为您解答关于mac怎么在python安装numpy库的疑问,此外,我

在本文中,我们将为您详细介绍在 macOS BigSur 上使用 Python 3.9.1 安装 Numpy 1.19.5 时遇到问题的相关知识,并且为您解答关于mac怎么在python安装numpy库的疑问,此外,我们还会提供一些关于CFUserNotificationDisplayAlert 在 macOS BigSur 中未显示警报窗口、Conda 3.9 不能在 macOS 上使用 numpy“原因:找不到图像”?、macOS BigSur Parallel Desktop 16 Win10 虚拟机无法连接网络、macOs BigSur 上 Makefile 中的 Bash if-condition 给出语法错误:文件意外结束的有用信息。

本文目录一览:

在 macOS BigSur 上使用 Python 3.9.1 安装 Numpy 1.19.5 时遇到问题(mac怎么在python安装numpy库)

在 macOS BigSur 上使用 Python 3.9.1 安装 Numpy 1.19.5 时遇到问题(mac怎么在python安装numpy库)

如何解决在 macOS BigSur 上使用 Python 3.9.1 安装 Numpy 1.19.5 时遇到问题

正如标题所说,我使用的是带有 Apple 芯片的 macOS Big Sur 11.1。我刚刚从 python.org 上的可下载链接安装了 Python 3.9.1。当我尝试按如下方式安装 Numpy 1.19.5 时:

python3 -m pip install numpy -U

我得到以下(截断的)输出:

Collecting numpy
  Using cached numpy-1.19.5.zip (7.3 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel Metadata ... done
Building wheels for collected packages: numpy
  Building wheel for numpy (PEP 517) ... error
.
.
.
  ----------------------------------------
  ERROR: Failed building wheel for numpy
Failed to build numpy
ERROR: Could not build wheels for numpy which use PEP 517 and cannot be installed directly

我试过将 numpy 降级如下:

python3 -m pip install numpy==1.15.3

我也遇到了类似的错误。提前致谢!

解决方法

这是因为 Numpy 还不能用于 Python 3.9 版。 只需使用 3.8 版创建一个新的 conda 环境:

conda create -n ENV_NAME python=3.8.5

...并通过 pip 安装 Numpy

pip install numpy

在 M1 和 macOS Big Sur 上的魅力十足。 此解决方法也是此 GitHub 问题的输出: https://github.com/numpy/numpy/issues/17807

CFUserNotificationDisplayAlert 在 macOS BigSur 中未显示警报窗口

CFUserNotificationDisplayAlert 在 macOS BigSur 中未显示警报窗口

如何解决CFUserNotificationDisplayAlert 在 macOS BigSur 中未显示警报窗口

我打算通过基于 C++ 的应用程序在 macOS 中显示警报消息。我正在使用 CFUserNotificationdisplayAlert 。下面是我用来显示警报窗口的一段代码:

  1. CFOptionFlags cfRes;
  2. CFUserNotificationdisplayAlert(0,kcfUserNotificationCautionAlertLevel,NULL,CFSTR("Message Header"),CFSTR("Message Body"),CFSTR("Ok"),&cfRes);

以上在 Catalina 上运行良好,但在 BigSur 中不显示警报窗口。

有什么我遗漏的吗?

Conda 3.9 不能在 macOS 上使用 numpy“原因:找不到图像”?

Conda 3.9 不能在 macOS 上使用 numpy“原因:找不到图像”?

如何解决Conda 3.9 不能在 macOS 上使用 numpy“原因:找不到图像”?

我刚刚为 conda 安装了一个 python3.9 环境。它适用于基本 python,但显然不适用于 numpy。错误是“原因:找不到图像”:

numpy 的安装已成功:

  1. conda install numpy
  2. The following NEW packages will be INSTALLED:
  3. blas conda-forge/osx-64::blas-2.106-openblas
  4. libblas conda-forge/osx-64::libblas-3.9.0-6_openblas
  5. libcblas conda-forge/osx-64::libcblas-3.9.0-6_openblas
  6. libgfortran conda-forge/osx-64::libgfortran-5.0.0-9_3_0_h6c81a4c_18
  7. libgfortran5 conda-forge/osx-64::libgfortran5-9.3.0-h6c81a4c_18
  8. liblapack conda-forge/osx-64::liblapack-3.9.0-6_openblas
  9. liblapacke conda-forge/osx-64::liblapacke-3.9.0-6_openblas
  10. libopenblas conda-forge/osx-64::libopenblas-0.3.12-openmp_h54245bb_1
  11. llvm-openmp conda-forge/osx-64::llvm-openmp-11.0.1-h7c73e74_0
  12. numpy pkgs/main/osx-64::numpy-1.19.2-py39h0fa1045_0
  13. numpy-base pkgs/main/osx-64::numpy-base-1.19.2-py39h3a452eb_0
  14. Proceed ([y]/n)?
  15. Preparing transaction: done
  16. Verifying transaction: done
  17. Executing transaction: done

安装 conda install ipython 也成功。但是 ipython 不起作用:

  1. $ipython
  2. Python 3.9.1 (default,Dec 11 2020,06:28:49)
  3. Type ''copyright'',''credits'' or ''license'' for more information
  4. IPython 7.20.0 -- An enhanced Interactive Python. Type ''?'' for help.
  5. In [1]: import numpy as np
  6. ---------------------------------------------------------------------------
  7. ImportError Traceback (most recent call last)
  8. ~/miniconda3/envs/python39/lib/python3.9/site-packages/numpy/core/__init__.py in <module>
  9. 21 try:
  10. ---> 22 from . import multiarray
  11. 23 except ImportError as exc:
  12. ~/miniconda3/envs/python39/lib/python3.9/site-packages/numpy/core/multiarray.py in <module>
  13. 11
  14. ---> 12 from . import overrides
  15. 13 from . import _multiarray_umath
  16. ~/miniconda3/envs/python39/lib/python3.9/site-packages/numpy/core/overrides.py in <module>
  17. 6
  18. ----> 7 from numpy.core._multiarray_umath import (
  19. 8 add_docstring,implement_array_function,_get_implementing_args)
  20. ImportError: dlopen(/Users/steve/miniconda3/envs/python39/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so,2): Library not loaded: @rpath/libopenblas.dylib
  21. Referenced from: /Users/steve/miniconda3/envs/python39/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so
  22. Reason: image not found
  23. During handling of the above exception,another exception occurred:
  24. ImportError Traceback (most recent call last)
  25. <ipython-input-1-0aa0b027fcb6> in <module>
  26. ----> 1 import numpy as np
  27. ~/miniconda3/envs/python39/lib/python3.9/site-packages/numpy/__init__.py in <module>
  28. 138 from . import _distributor_init
  29. 139
  30. --> 140 from . import core
  31. 141 from .core import *
  32. 142 from . import compat
  33. ~/miniconda3/envs/python39/lib/python3.9/site-packages/numpy/core/__init__.py in <module>
  34. 46 """ % (sys.version_info[0],sys.version_info[1],sys.executable,47 __version__,exc)
  35. ---> 48 raise ImportError(msg)
  36. 49 finally:
  37. 50 for envkey in env_added:
  38. ImportError:
  39. IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
  40. Importing the numpy C-extensions Failed. This error can happen for
  41. many reasons,often due to issues with your setup or how NumPy was
  42. installed.
  43. We have compiled some common reasons and troubleshooting tips at:
  44. https://numpy.org/devdocs/user/troubleshooting-importerror.html
  45. Please note and check the following:
  46. * The Python version is: python3.9 from "/Users/steve/miniconda3/envs/python39/bin/python"
  47. * The NumPy version is: "1.19.2"
  48. and make sure that they are the versions you expect.
  49. Please carefully study the documentation linked above for further help.
  50. Original error was: dlopen(/Users/steve/miniconda3/envs/python39/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so,2): Library not loaded: @rpath/libopenblas.dylib
  51. Referenced from: /Users/steve/miniconda3/envs/python39/lib/python3.9/site-packages/numpy/core/_multiarray_umath.cpython-39-darwin.so
  52. Reason: image not found

我在 macOS Catalina

解决方法

通道混合:不兼容的二进制文件

一个可能的问题是频道混合。不同的通道通常使用不同的构建堆栈,这会导致引用链接库中的不同符号。在这种情况下,请尝试确保所有内容都来自 conda-forge,例如

  1. conda install -c conda-forge conda-forge::numpy

从长远来看,可能会考虑将 conda-forge 添加到全局频道配置中,并可能将优先级设置为 "strict"。见conda config --describe channels channel_priority。此外,--env 标志对于以特定于环境的方式更改此类设置很有用。

macOS BigSur Parallel Desktop 16 Win10 虚拟机无法连接网络

macOS BigSur Parallel Desktop 16 Win10 虚拟机无法连接网络

@H_301_3@

macOS BigSur 上的 Parallel Desktop 安装 Win10 虚拟机无法连接网络

  • 问题描述
  • 解决办法
    • 前往访达「/Library/Preferences/Parallels」文件夹
    • 修改「dispatcher.desktop.xml」和「network.desktop.xml」文件
    • 重启 Parallel Desktop 16

问题描述

在 MacBook Pro 上通过 Boot Camp 安装 Win10 ,使用完全正常,但是在 macOS 中通过 Parallel Desktop 虚拟化运行 Win10 会出现无法联网的情况,第一次打开显示如下错误:

网络初始化失败。

不仅如此,还遇到了无法连接 USB 设备等一些问题。

解决办法

最开始我安装的是破解版 Parallel Desktop 16 (垃圾人行为,不要学习!!!),重装了正版也没能解决。
目前应该是只有在 Big Sur 上会出现这些问题,解决办法如下:

前往访达「/Library/Preferences/Parallels」文件夹

  • 关闭 Parallel Desktop 16,软件下面没有小点那种关闭
  • 打开访达,快捷键「shift」+「command」+「G」
  • 输入路径「/Library/Preferences/Parallels」

修改「dispatcher.desktop.xml」和「network.desktop.xml」文件

  • 将「dispatcher.desktop.xml」和「network.desktop.xml」文件移到桌面
  • 用文本编辑打开「network.desktop.xml」
  • 修改第五行 0 最中间数字为0

「network.desktop.xml」文件

  • 同样,使用文本编辑打开「dispatcher.desktop.xml」
  • 使用「command」+「F」快捷键,搜索「0」,将中间的「0」改为「1」

「dispatcher.desktop.xml」文件

  • 两个文件修改完成后保存退出,再将其拖回原文件夹,弹出对话框选择替换,并按要求输入密码

选择替换

重启 Parallel Desktop 16

  • 重启后若依旧无法使用网络,可检查 Parallel 虚拟机配置中网络选项

虚拟机配置

  • 这样一来以上的一些问题就能解决了

macOs BigSur 上 Makefile 中的 Bash if-condition 给出语法错误:文件意外结束

macOs BigSur 上 Makefile 中的 Bash if-condition 给出语法错误:文件意外结束

如何解决macOs BigSur 上 Makefile 中的 Bash if-condition 给出语法错误:文件意外结束

我在 Makefile 中有这个代码

SHELL=/bin/bash

define PYTHON_VERSION
3.7.4
endef

define DEFAULT
echo BUILD_ENV:

  if [ -z "$(PYTHON_VERSION)" ]
  then
    printf ''$(PYTHON_VERSION) is empty.\\n''
    exit 1
  fi
endef

default:
    $(DEFAULT)

build:
    $(DEFAULT)

它给了我(运行 make build):

echo BUILD_ENV: BUILD_ENV: if [ -z "3.7.4" ] then printf ''3.7.4 is empty.\\n'' exit 1 /bin/bash: -c: 第 1 行:语法错误:文件意外结束

如何修复这个错误? (它发生在 macOS BigSur 上)

关于在 macOS BigSur 上使用 Python 3.9.1 安装 Numpy 1.19.5 时遇到问题mac怎么在python安装numpy库的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于CFUserNotificationDisplayAlert 在 macOS BigSur 中未显示警报窗口、Conda 3.9 不能在 macOS 上使用 numpy“原因:找不到图像”?、macOS BigSur Parallel Desktop 16 Win10 虚拟机无法连接网络、macOs BigSur 上 Makefile 中的 Bash if-condition 给出语法错误:文件意外结束等相关内容,可以在本站寻找。

本文标签: