Linux 系统中 NumPy (Python 2) 编程环境

news/2024/7/7 15:35:20 标签: Linux 系统, NumPy, Python 2, 编程环境

Linux 系统NumPy [Python 2] 编程环境

  • 1. Installation
  • 2. NumPy 版本
  • 3. NumPy 目录 - `/home/strong/.local/lib/python2.7/site-packages/numpy/core/include`
  • 4. NumPy 目录 - `/usr/local/lib/python2.7/dist-packages/numpy/core/include`
  • 5. sudo pip install numpy
  • 6. sudo apt-get install python-numpy
  • 7. fatal error: numpy/arrayobject.h: No such file or directory
  • References

1. Installation

strong@foreverstrong:~$ sudo apt-get install python-numpy

NumPy__8">2. NumPy 版本

strong@foreverstrong:~$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> print(numpy.version)
<module 'numpy.version' from '/home/strong/.local/lib/python2.7/site-packages/numpy/version.pyc'>
>>> print(numpy.version.version)
1.13.3
>>> exit()
strong@foreverstrong:~$ 

NumPy___homestronglocallibpython27sitepackagesnumpycoreinclude_24">3. NumPy 目录 - /home/strong/.local/lib/python2.7/site-packages/numpy/core/include

strong@foreverstrong:~$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.get_include()
'/home/strong/.local/lib/python2.7/site-packages/numpy/core/include'
>>> exit()
strong@foreverstrong:~$

NumPy___usrlocallibpython27distpackagesnumpycoreinclude_38">4. NumPy 目录 - /usr/local/lib/python2.7/dist-packages/numpy/core/include

strong@foreverstrong:~$ python
Python 2.7.12 (default, Nov 12 2018, 14:36:49) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.get_include()
'/usr/local/lib/python2.7/dist-packages/numpy/core/include'
>>> exit()
strong@foreverstrong:~$

5. sudo pip install numpy

NumPy 目录 - /usr/local/lib/python2.7/dist-packages/numpy/core/include

strong@foreverstrong:~$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.get_include()
'/home/strong/.local/lib/python2.7/site-packages/numpy/core/include'
>>> exit()
strong@foreverstrong:~$ 
 
strong@foreverstrong:~$ sudo apt-get update
...
Reading package lists... Done
strong@foreverstrong:~$ 
 
strong@foreverstrong:~$ sudo apt-get install python-numpy
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-numpy is already the newest version (1:1.11.0-1ubuntu1).
The following packages were automatically installed and are no longer required:
  gimp-data libamd2.4.1 libbabl-0.1-0 libcamd2.4.1 libccolamd2.9.1 libcholmod3.0.6 libgcrypt20:i386
  libgegl-0.3-0 libgimp2.0 libsystemd0:i386 libumfpack5.7.1
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 524 not upgraded.
strong@foreverstrong:~$ 
 
strong@foreverstrong:~$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> print(numpy.version)
<module 'numpy.version' from '/home/strong/.local/lib/python2.7/site-packages/numpy/version.pyc'>
>>> print(numpy.version.version)
1.13.3
>>> exit()
strong@foreverstrong:~$ 
 
strong@foreverstrong:~$ sudo apt-get purge --auto-remove python-numpy
[sudo] password for strong: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  gimp-data* libamd2.4.1* libbabl-0.1-0* libcamd2.4.1* libccolamd2.9.1* libcholmod3.0.6* libgcrypt20:i386*
  libgegl-0.3-0* libgimp2.0* libjs-jquery-ui* libsystemd0:i386* libumfpack5.7.1* python-cycler*
  python-dateutil* python-decorator* python-joblib* python-matplotlib* python-matplotlib-data* python-nose*
  python-numpy* python-opencv* python-pyparsing* python-scipy* python-simplejson* python-sklearn*
  python-sklearn-lib* python-tz*
0 upgraded, 0 newly installed, 27 to remove and 521 not upgraded.
After this operation, 147 MB disk space will be freed.
...
strong@foreverstrong:~$ 
 
strong@foreverstrong:~$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.get_include()
'/home/strong/.local/lib/python2.7/site-packages/numpy/core/include'
>>> exit()
strong@foreverstrong:~$ 
 
strong@foreverstrong:~$ pip list
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
Package                            Version    
---------------------------------- -----------
adium-theme-ubuntu                 0.3.4      
attrs                              15.2.0     
...
notebook                           5.5.0      
numpy                              1.13.3     
olefile                            0.44       
...     
You are using pip version 18.0, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
strong@foreverstrong:~$ 
 
strong@foreverstrong:~$ pip install numpy
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
Requirement already satisfied: numpy in ./.local/lib/python2.7/site-packages (1.13.3)
You are using pip version 18.0, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
strong@foreverstrong:~$
 
strong@foreverstrong:~$ sudo pip uninstall numpy
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
The directory '/home/strong/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Uninstalling numpy-1.13.3:
  Would remove:
    /home/strong/.local/bin/f2py
    /home/strong/.local/lib/python2.7/site-packages/numpy-1.13.3.dist-info/*
    /home/strong/.local/lib/python2.7/site-packages/numpy/*
Proceed (y/n)? y
  Successfully uninstalled numpy-1.13.3
The directory '/home/strong/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
You are using pip version 18.0, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
strong@foreverstrong:~$ 
 
strong@foreverstrong:~$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.get_include()
'/usr/local/lib/python2.7/dist-packages/numpy/core/include'
>>> exit()
strong@foreverstrong:~$ 
 
strong@foreverstrong:~$ sudo pip uninstall numpy
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
The directory '/home/strong/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Uninstalling numpy-1.13.3:
  Would remove:
    /usr/local/bin/f2py
    /usr/local/lib/python2.7/dist-packages/numpy-1.13.3.dist-info/*
    /usr/local/lib/python2.7/dist-packages/numpy/*
Proceed (y/n)? y
  Successfully uninstalled numpy-1.13.3
The directory '/home/strong/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
You are using pip version 18.0, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
strong@foreverstrong:~$ 
 
strong@foreverstrong:~$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>> exit()
strong@foreverstrong:~$ 
 
strong@foreverstrong:~$ sudo pip install numpy
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
The directory '/home/strong/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/strong/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting numpy
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb926730a50>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /packages/e0/b5/63b79fe426433fa1cd110eb04a94ec0c6967e56e5f57c98caf455a5fb6e2/numpy-1.16.1-cp27-cp27mu-manylinux1_x86_64.whl
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb926730ed0>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /packages/e0/b5/63b79fe426433fa1cd110eb04a94ec0c6967e56e5f57c98caf455a5fb6e2/numpy-1.16.1-cp27-cp27mu-manylinux1_x86_64.whl
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7fb925c24310>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',)': /packages/e0/b5/63b79fe426433fa1cd110eb04a94ec0c6967e56e5f57c98caf455a5fb6e2/numpy-1.16.1-cp27-cp27mu-manylinux1_x86_64.whl
  Downloading https://files.pythonhosted.org/packages/e0/b5/63b79fe426433fa1cd110eb04a94ec0c6967e56e5f57c98caf455a5fb6e2/numpy-1.16.1-cp27-cp27mu-manylinux1_x86_64.whl (17.0MB)
    100% |████████████████████████████████| 17.0MB 2.2MB/s 
Installing collected packages: numpy
Successfully installed numpy-1.16.1
strong@foreverstrong:~$ 
 
strong@foreverstrong:~$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.get_include()
'/usr/local/lib/python2.7/dist-packages/numpy/core/include'
>>> exit()
strong@foreverstrong:~$ 

6. sudo apt-get install python-numpy

NumPy 目录 - /usr/lib/python2.7/dist-packages/numpy/core/include

strong@foreverstrong:~$ pip uninstall numpy
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
Uninstalling numpy-1.16.1:
  Would remove:
    /usr/local/bin/f2py
    /usr/local/bin/f2py2
    /usr/local/bin/f2py2.7
    /usr/local/lib/python2.7/dist-packages/numpy-1.16.1.dist-info/*
    /usr/local/lib/python2.7/dist-packages/numpy/*
Proceed (y/n)? y
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/basecommand.py", line 141, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/commands/uninstall.py", line 74, in run
    auto_confirm=options.yes, verbose=self.verbosity > 0,
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/req/req_install.py", line 864, in uninstall
    uninstalled_pathset.remove(auto_confirm, verbose)
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/req/req_uninstall.py", line 221, in remove
    renames(path, new_path)
  File "/usr/local/lib/python2.7/dist-packages/pip/_internal/utils/misc.py", line 276, in renames
    shutil.move(old, new)
  File "/usr/lib/python2.7/shutil.py", line 303, in move
    os.unlink(src)
OSError: [Errno 13] Permission denied: '/usr/local/bin/f2py'
You are using pip version 18.0, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
strong@foreverstrong:~$
 
strong@foreverstrong:~$ sudo pip uninstall numpy
[sudo] password for strong: 
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)
The directory '/home/strong/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Uninstalling numpy-1.16.1:
  Would remove:
    /usr/local/bin/f2py
    /usr/local/bin/f2py2
    /usr/local/bin/f2py2.7
    /usr/local/lib/python2.7/dist-packages/numpy-1.16.1.dist-info/*
    /usr/local/lib/python2.7/dist-packages/numpy/*
Proceed (y/n)? y
  Successfully uninstalled numpy-1.16.1
The directory '/home/strong/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
You are using pip version 18.0, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
strong@foreverstrong:~$ 
 
strong@foreverstrong:~$ python 
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>> exit()
strong@foreverstrong:~$ 
 
strong@foreverstrong:~$ sudo apt-get update
...                                                                                
Reading package lists... Done
strong@foreverstrong:~$
 
strong@foreverstrong:~$ sudo apt-get install python-numpy
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  python-nose python-numpy-dbg python-numpy-doc
The following NEW packages will be installed:
  python-numpy
0 upgraded, 1 newly installed, 0 to remove and 521 not upgraded.
Need to get 1,763 kB of archives.
After this operation, 9,598 kB of additional disk space will be used.
Get:1 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 python-numpy amd64 1:1.11.0-1ubuntu1 [1,763 kB]
Fetched 1,763 kB in 30s (57.5 kB/s)                                                                                               
Selecting previously unselected package python-numpy.
(Reading database ... 300164 files and directories currently installed.)
Preparing to unpack .../python-numpy_1%3a1.11.0-1ubuntu1_amd64.deb ...
Unpacking python-numpy (1:1.11.0-1ubuntu1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up python-numpy (1:1.11.0-1ubuntu1) ...
strong@foreverstrong:~$ 
 
strong@foreverstrong:~$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.get_include()
'/usr/lib/python2.7/dist-packages/numpy/core/include'
>>> exit()
strong@foreverstrong:~$ 

7. fatal error: numpy/arrayobject.h: No such file or directory

出现 fatal error: numpy/arrayobject.h: No such file or directory 问题,请核实 makefile 中指定的 Python 路径与系统中实际的 Python 路径是否一致。

NumPy 目录 - /home/strong/.local/lib/python2.7/site-packages/numpy/core/include
sudo pip install numpy - NumPy 目录 - /usr/local/lib/python2.7/dist-packages/numpy/core/include
sudo apt-get install python-numpy - NumPy 目录 - /usr/lib/python2.7/dist-packages/numpy/core/include
strong@foreverstrong:~$ python -c "import numpy; print(numpy.get_include())"
/usr/lib/python2.7/dist-packages/numpy/core/include
strong@foreverstrong:~$
strong@foreverstrong:~$ python -c "import numpy; print(numpy.get_include())"
/home/strong/.local/lib/python2.7/site-packages/numpy/core/include
strong@foreverstrong:~$

References

[1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/


http://www.niftyadmin.cn/n/5452230.html

相关文章

脏牛提权(靶机复现)

目录 一、脏牛漏洞概述 二、漏洞复现 1.nmap信息收集 1.1.查看当前IP地址 1.2.扫描当前网段&#xff0c;找出目标机器 1.3.快速扫描目标机全端口 三、访问收集到的资产 192.168.40.134:80 192.168.40.134:1898 四、msf攻击 1.查找对应exp 2.选择对应exp并配置相关设…

为什么独享ip会更高效?

随着互联网的蓬勃发展&#xff0c;代理IP因其特性&#xff0c;也备受关注&#xff0c;代理IP又有分共享代理IP和独享代理IP&#xff0c;但&#xff0c;无论是在数据采集方面&#xff0c;还是在其他业务场景上&#xff0c;独享代理IP似乎会更受用户欢迎一点&#xff0c;这到底是…

在树莓派4B上安装Ubuntu Server 20

在树莓派4B上安装Ubuntu Server 20 树莓派是一个广受欢迎的小型单板计算机&#xff0c;它可以用于各种项目&#xff0c;从家庭自动化到网络服务器。Ubuntu Server 20是一个轻量级、高效的操作系统&#xff0c;非常适合在树莓派上运行。本文将指导你如何在树莓派上安装Ubuntu S…

RHCE:请给openlab搭建web

1.关闭所有安全软件已经防火墙 2.安装所需软件 3.在Windows 文件中进行DNS映射 C:\Windows\System32\drivers\etc\hosts 文件进 行DNS 映射 4.创建www.openlab.com网站 5.创建教学资料子网站 6.创建学生信息子网站 进行验证 7.创建缴费子网站

【C++】每日一题 45 跳跃游戏

给定一个长度为 n 的 0 索引整数数组 nums。初始位置为 nums[0]。 每个元素 nums[i] 表示从索引 i 向前跳转的最大长度。换句话说&#xff0c;如果你在 nums[i] 处&#xff0c;你可以跳转到任意 nums[i j] 处: 0 < j < nums[i] i j < n 返回到达 nums[n - 1] 的最…

基于冠豪猪优化器(CPO)的无人机路径规划

该优化算法是2024年新发表的一篇SCI一区top论文具有良好的实际应用和改进意义。一键运行main函数代码自动保存高质量图片 1、冠豪猪优化器 摘要&#xff1a;受冠豪猪(crest Porcupine, CP)的各种防御行为启发&#xff0c;提出了一种新的基于自然启发的元启发式算法——冠豪猪…

什么是希尔排序

排序原理&#xff1a; 将一组数组分成若干份&#xff0c;每份里的数比较并排序&#xff0c;最后再将所有的总体排序。 例子&#xff1a; 给这个数组排序{1&#xff0c;9&#xff0c;6&#xff0c;4&#xff0c;8&#xff0c;5&#xff0c;3&#xff0c;2} 一般都是第一次分成…

2024年开年京东云送福利,云服务仅需50元起

2024年开年京东云送福利&#xff0c;云服务仅需50元起 大品牌无需担心跑路&#xff01; 轻量云主机2C2G-40G SSD系统盘-3M带宽-200G月流量&#xff0c;优惠价格&#xff1a;5.8元1个月 轻量云主机2C4G-60G SSD系统盘-5M带宽-500G月流量&#xff0c;优惠价格&#xff1a;8.8元…