python - 在没有 pip/anaconda 的 Ubuntu 上安装 numpy

标签 python numpy ubuntu

不使用 anaconda or pip , 安装时 numpy在 Ubuntu 和打印 numpy 版本上,我得到这个:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 17, in <module>
    from . import multiarray
  File "/usr/lib/python3/dist-packages/numpy/core/multiarray.py", line 14, in <module>
    from . import overrides
  File "/usr/lib/python3/dist-packages/numpy/core/overrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "basicVersions.py", line 2, in <module>
    import numpy as np
  File "/usr/lib/python3/dist-packages/numpy/__init__.py", line 142, in <module>
    from . import core
  File "/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 47, 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 "/usr/bin/python3.7",
     and that you have no directories in your PATH or PYTHONPATH that can
     interfere with the Python and numpy version "1.17.4" 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: No module named 'numpy.core._multiarray_umath'

在所有论坛上,给出的安装步骤都是在 pip/anaconda 的上下文中。我没有找到很多关于通过 apt/apt-get 在 Ubuntu 上安装的引用资料。这看起来像安装错误,所以我也尝试了这个,但没有运气。请帮忙!
sudo apt install numpy
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package numpy
~/python$ sudo apt install python3-numpy
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-numpy is already the newest version (1:1.17.4-5ubuntu3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

这可能是python版本问题吗?
这是我正在尝试的代码:
import sys
import numpy as np
import matplotlib

print("Python: ", sys.version)
print("Numpy: ", np.__version__)
print("Matplotlib: ", matplotlib.__version__)

最佳答案

解决方案是使用 python3作为命令而不是 python3.7可以用这个结论将问题标记为已关闭。

关于python - 在没有 pip/anaconda 的 Ubuntu 上安装 numpy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61446931/

相关文章:

python - Groupby-shift、保存列

python - 如何在 Python 的 curses 中获得更多颜色?

python - numpy 或 scipy 有哪些可能的计算可以返回 NaN?

python - 在 Python 中从多维数组中迭代和选择特定数组

c++ - OpenCV VideoCapture 根本无法从我的网络摄像头读取

python - pycodestyle:在项目方面忽略指令

python - 如何使用 python(pandas) 更新 csv 文件中所有行的最后一列值

python - numpy einsum : nested dot products

linux - 无法运行存在的文件

r - 在没有浏览器的情况下在 AWS Ubuntu 上验证谷歌表格