【问题标题】:How to upgrade numpy without changing linux distributions in ubuntu如何在不更改 ubuntu 中的 linux 发行版的情况下升级 numpy
【发布时间】:2016-11-10 13:28:22
【问题描述】:

我的 15.10 Ubuntu 机器上有 numpy 1.11,我需要在 12.04 机器上使用相同的版本。我不确定这是否可能,并且对 linux 了解不够了解。

我试过了

sudo pip install numpy --upgrade
sudo apt-get dist-upgrade

我尝试重新安装等,但似乎没有任何效果。这些库是根本不兼容还是有办法做到这一点?

我不想弄乱 ubuntu 版本,因为这是一个共享的实验室机器,我担心如果我这样做了其他人的实验可能会出现问题。

编辑:当我运行升级时,它说它已成功安装,但没有说明版本。

这是我运行升级时输出的结尾:

types -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/numpy/random/mtrand/mtrand.o build/temp.linux-x86_64-2.7/numpy/random/mtrand/randomkit.o build/temp.linux-x86_64-2.7/numpy/random/mtrand/initarray.o build/temp.linux-x86_64-2.7/numpy/random/mtrand/distributions.o -Lbuild/temp.linux-x86_64-2.7 -o build/lib.linux-x86_64-2.7/numpy/random/mtrand.so
Creating build/scripts.linux-x86_64-2.7/f2py
  adding 'build/scripts.linux-x86_64-2.7/f2py' to scripts
changing mode of build/scripts.linux-x86_64-2.7/f2py from 644 to 755

warning: no previously-included files matching '*.pyo' found anywhere in distribution
warning: no previously-included files matching '*.pyd' found anywhere in distribution
changing mode of /usr/local/bin/f2py to 755
Successfully installed numpy
Cleaning up...

当我检查我的版本时:

>>> import numpy
>>> numpy.version.version
'1.8.2'

【问题讨论】:

  • 我可以建议接受答案吗?

标签: python linux ubuntu numpy


【解决方案1】:

运行时会发生什么

sudo pip install numpy --upgrade

当我运行它时,我得到了这个:

Does it Collecting numpy
  Downloading numpy-1.11.1.zip (4.7MB)
    100% |████████████████████████████████| 4.7MB 108kB/s 
Installing collected packages: numpy
  Found existing installation: numpy 1.9.2
    Uninstalling numpy-1.9.2:
      Successfully uninstalled numpy-1.9.2
  Running setup.py install for numpy

如果你看到这个,我的下一个问题是:你确定你的路径设置正确吗?

【讨论】:

  • 运行“sudo pip install numpy --upgrade”会下载一堆包。最后我得到:创建 build/scripts.linux-x86_64-2.7/f2py 将 'build/scripts.linux-x86_64-2.7/f2py' 添加到脚本中,从 644 更改 build/scripts.linux-x86_64-2.7/f2py 的模式到 755 警告:在分发中的任何地方都找不到与“.pyo”匹配的先前包含的文件警告:在 /usr/local/bin 的分发更改模式中的任何地方都找不到与“.pyd”匹配的先前包含的文件/f2py to 755 安装成功 numpy 清理...
  • 我在我的问题中更好地发布了输出。它更容易阅读。我没有看到你是什么。
【解决方案2】:

我发现使用 Anaconda python 发行版来管理你的 python 环境更加可靠和可重复。你可以使用 conda 作为你的 python 包管理系统,而不是使用 apt-get,它应该在各个平台上相当一致地工作,尤其是对于像 numpy 这样的主要包。

【讨论】:

  • 这是一个有用的评论。经过调查 apt-get 是问题所在。
【解决方案3】:

好的,我解决了我的问题。我将问题总结一下:

当我通过安装 scipy 包安装 Scipy 时,它会自动重新安装 numpy 1.8,不管它是什么,即使它只是:

sudo apt-get install python-scipy

什么对我有用:

sudo apt-get purge python-numpy
sudo pip install numpy
sudo pip install scipy
sudo pip install -U scikit-learn

我不知道为什么 apt-get 包没有更新,也许这是一个存在的问题。谢谢大家的帮助。 :-)

【讨论】:

    【解决方案4】:

    这应该可以工作

    pip install --upgrade numpy 
    

    您能发布您收到的错误消息吗?

    下次您处理项目时,您可以使用virtualenvvirtualenv 将为您的每个项目创建一个隔离环境,其中包含 python 二进制文件的副本、整个 Python 标准库、pip 安装程序以及站点包目录的副本。这样,环境对您来说是本地的,不会影响 Python 的版本或其对所有用户帐户的依赖关系。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-12
    • 1970-01-01
    • 2021-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多