简体   繁体   English

在Virtualenv中安装Scipy

[英]Installing Scipy in Virtualenv

I've tried many ways to install scipy but without successes. 我尝试了许多安装scipy的方法,但没有成功。 I use virtualenv on Linux Mate. 我在Linux Mate上使用virtualenv。 After the workon command I tried 在workon命令之后,我尝试了

pip install scipy

or 要么

easy_install scipy

end every time is a "failed with exit status 1" 每次结束都是“失败,退出状态为1”

I tried also 我也尝试过

apt-get install python-scipy

and I've no errors but if I run python 而且我没有错误,但是如果我运行python

python
import scipy

I'll have "ImportError: No module named scipy" What is wrong? 我将看到“ ImportError:没有名为scipy的模块”这是什么问题?

I'd suggest using Miniconda to install scipy. 我建议使用Miniconda安装scipy。

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

Then, create a Conda environment with scipy installed: 然后,创建一个安装了scipy的Conda环境:

conda create -n scipy scipy

Now you'll have access to the activate and deactivate scripts, used to open and close Conda environments. 现在,您可以访问用于打开和关闭Conda环境的activatedeactivate脚本。

$ 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'

[Edit] You indicated you want to use the system installed scipy package, that you have successfully installed via apt, in a virtualenv. [编辑]您表示要使用在virtualenv中通过apt成功安装的系统安装scipy软件包。 You can instruct virtualenv to create a new environment that includes all the system Python packages like this: 您可以指示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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM