【问题标题】:Installing Scipy in Virtualenv在 Virtualenv 中安装 Scipy
【发布时间】:2016-03-19 05:47:43
【问题描述】:

我尝试了很多方法来安装 scipy,但都没有成功。我在 Linux Mate 上使用 virtualenv。 在 workon 命令之后我尝试了

pip install scipy

easy_install scipy

每次结束都是“失败,退出状态为 1”

我也试过了

apt-get install python-scipy

我没有错误,但如果我运行 python

python
import scipy

我会有“ImportError: No module named scipy” 怎么了?

【问题讨论】:

  • 您可以使用Anaconda。它带有 Scipy。

标签: python linux scipy virtualenv


【解决方案1】:

我建议使用 Miniconda 安装 scipy。

wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh
bash Miniconda-latest-Linux-x86_64.sh -b

然后,创建一个安装了 scipy 的 Conda 环境:

conda create -n scipy scipy

现在您可以访问 activatedeactivate 脚本,用于打开和关闭 Conda 环境。

$ source activate scipy
discarding /Users/username/miniconda/bin from PATH
prepending /Users/username/miniconda/envs/scipy/bin to PATH
(scipy)$ python
Python 2.7.11 |Continuum Analytics, Inc.| (default, Dec  6 2015, 18:57:58) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import scipy
>>> scipy.version.version
'0.16.0'

[编辑] 你表示你想使用系统安装的scipy 包,你已经通过apt成功安装在一个virtualenv中。您可以指示virtualenv 创建一个包含所有系统 Python 包的新环境,如下所示:

$ virtualenv --system-site-packages scipy_env
New python executable in scipy_env/bin/python
Installing setuptools, pip...done.
$ source scipy_env/bin/activate
(scipy_env)$ python
Python 2.7.10 (default, Jul 14 2015, 19:46:27) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy

【讨论】:

  • 我对 virtualenv 有什么改变吗?
  • Conda 将与 virtualenv 并存。如果需要,您还可以在 Conda 环境中使用 pip。它只允许您安装二进制文件,而不是通过 pip(您的第一个问题)或过时的 apt 包(可能是您的第二个问题的原因)进行编译。
  • 如果我停用我的环境并 digit pip install scipy,我将阅读“要求已经满足(使用 --upgrade 升级):/usr/lib/python2.7/dist-packages 中的 scipy ”。我可以将此链接到我的虚拟环境吗?
  • 现有的 scipy 是 apt-get install python-scipy 的结果。可以将其链接到 virtualenv,但我认为pip freeze 您现有的环境会更容易,并使用 scipy 在 Conda 环境中安装这些包。
  • 编辑部分和我想要的差不多。我的虚拟环境调用 webpy。是否有可能有类似的东西:workon webpy ... python...import scipy
猜你喜欢
  • 2015-02-28
  • 1970-01-01
  • 1970-01-01
  • 2013-12-04
  • 2012-07-14
  • 2012-10-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多