I have successfully installed scipy
in the default python compiler on an amazon ec2 micro instance (Ubuntu 13.04). However i am not able to install scipy
in a virtualenv.
我已经成功地将scipy安装在amazon ec2微实例的默认python编译器上(Ubuntu 13.04)。但是我不能在一个virtualenv中安装scipy。
pip install scipy
ends with this error
pip安装scipy以这个错误结束
scipy/sparse/sparsetools/csr_wrap.cxx: In function ‘void init_csr()’:
scipy/sparse/sparsetools/csr_wrap.cxx:73303:21: warning: variable ‘md’ set but not used [-Wunused-but-set-variable]
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.7/README.Bugs> for instructions.
----------------------------------------
Cleaning up...
Command /home/ubuntu/pnr/bin/python -c "import setuptools;__file__='/home/ubuntu/pnr/build/scipy/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-t8Drvd-record/install-record.txt --single-version-externally-managed --install-headers /home/ubuntu/pnr/include/site/python2.7 failed with error code -9 in /home/ubuntu/pnr/build/scipy
and
和
Traceback (most recent call last):
File "/home/ubuntu/pnr/bin/pip", line 9, in <module>
load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
File "/home/ubuntu/pnr/local/lib/python2.7/site-packages/pip/__init__.py", line 148, in main
return command.main(args[1:], options)
File "/home/ubuntu/pnr/local/lib/python2.7/site-packages/pip/basecommand.py", line 169, in main
text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 53: ordinal not in range(128)
Before anyone asks. pip freeze
for default compiler returns
之前有人问。pip冻结默认编译器返回
Cheetah==2.4.4
Landscape-Client==12.12
M2Crypto==0.21.1
PAM==0.4.2
Pillow==2.0.0
PyYAML==3.10
Twisted-Core==12.3.0
Twisted-Names==12.3.0
Twisted-Web==12.3.0
apt-xapian-index==0.45
argparse==1.2.1
boto==2.3.0
chardet==2.0.1
cloud-init==0.7.2
configobj==4.7.2
distribute==0.6.34
distro-info==0.10
euca2ools==2.1.1
numpy==1.7.1
oauth==1.0.1
paramiko==1.7.7.1
prettytable==0.6.1
pyOpenSSL==0.13
pycrypto==2.6
pycurl==7.19.0
pygobject==3.8.0
pyserial==2.6
python-apt==0.8.8ubuntu6
python-debian==0.1.21-nmu2ubuntu1
requests==1.1.0
scipy==0.11.0
six==1.2.0
ssh-import-id==3.14
urllib3==1.5
virtualenv==1.10.1
wsgiref==0.1.2
zope.interface==4.0.5
pip freeze
command for virtualenv returns
pip冻结命令返回virtualenv
Cython==0.19.2
Flask==0.10.1
Flask-Bootstrap==3.0.0.1
Flask-WTF==0.9.3
Jinja2==2.7.1
MarkupSafe==0.18
WTForms==1.0.5
Werkzeug==0.9.4
argparse==1.2.1
beautifulsoup4==4.3.2
itsdangerous==0.23
numpy==1.7.1
pymongo==2.6.2
requests==2.0.0
wsgiref==0.1.2
5 个解决方案
#1
99
One solution is to temporarily enable swap on your micro instance. As described at this SO post, enable 1gb swap via:
一种解决方案是在您的微实例上临时启用交换。如本文所述,通过以下方式启用1gb交换:
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1
Once swap is on, install scipy via pip:
交换器打开后,通过pip安装scipy:
sudo apt-get install -y libatlas-base-dev gfortran python-dev build-essential g++
sudo pip install numpy
sudo pip install scipy
Once scipy successfully installs, you can disable it via:
一旦scipy成功安装,您可以通过以下方式禁用它:
sudo swapoff /var/swap.1
sudo rm /var/swap.1
#2
25
This worked for me:
这工作对我来说:
pip --no-cache-dir install scipy
See:
看到的:
-
Memory error while using pip install Matplotlib
使用pip安装Matplotlib时内存错误
https://github.com/pypa/pip/blob/9a23d4ed119327d3b823ec223aaead90964bac58/pip/basecommand.py#L56-L63
https://github.com/pypa/pip/blob/9a23d4ed119327d3b823ec223aaead90964bac58/pip/basecommand.py L56-L63
-
https://github.com/pypa/pip/blob/28cca11e284b37cc2c7977fd25be6f494adda9d3/src/pip/_internal/download.py L359-L367
note:
注意:
- works for other service providers, hardware, VMs, and containers.
- 适用于其他服务提供者、硬件、vm和容器。
- if RAM allocation size of 1GB
- 如果RAM分配大小为1GB。
- just calculate the diff between the cached directory memory usage and available ram
- 只需计算缓存的目录内存使用和可用ram之间的差异
#3
8
Yes, 512MB is not enough for compiling that C++ file.
是的,512MB对于编译c++文件来说是不够的。
Your best option is to build Scipy as a binary package (bdist, or eggs, or, more modern wheels) e.g. via python setupegg.py bdist_egg
on a different machine with compatible environment. For instance, use a similar Linux version to the EC2 instance in a virtual machine.
您最好的选择是将Scipy构建为一个二进制包(bdist或eggs,或更现代的车轮),例如通过python setupegg。在另一台具有兼容环境的机器上运行的py bdist_egg。例如,在虚拟机中使用与EC2实例相似的Linux版本。
In general, it's good to remember that when pip
installs packages, it compiles source files. If the package is not tiny, this is inefficient and it's better to use binary packages. The wheel
package format is supposed to play well together with pip.
通常,最好记住,当pip安装包时,它会编译源文件。如果包不是很小,那么这是低效的,最好使用二进制包。轮包格式应该与pip配合得很好。
#4
2
for me the error was slightly different.
对我来说,这个错误有点不同。
Blas (http://www.netlib.org/blas/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [blas]) or by setting
the BLAS environment variable.
----------------------------------------
Cleaning up...
Command /home/kdixit/pyvirt/bin/python -c "import setuptools;__file__='/home/kdixit/pyvirt/build/scipy/setup.py';exec(compile(open(__file__).read().replace('\r\n
Thus I had to install
因此我不得不安装
sudo apt-get install libblas-dev
and then it worked.
然后它工作。
#5
1
I was getting an out of virtual memory error during the scipy
compilation on a t2.micro
, I think numpy
compiled just fine. Anyway, I guess that Dolan Antenucci's answer would fix my issue, but instead I went another route, a compromise, which does work.
在t2的scipy编译过程中,我得到了一个虚拟内存错误。微,我觉得numpy编译得很好。不管怎么说,我想多兰·安图西的回答会解决我的问题,但我走了另一条路,一个妥协,这是可行的。
I'm running an Ubuntu
instance so keep that in mind.
我正在运行一个Ubuntu实例,所以请记住这一点。
sudo apt-get -y install python-scipy && echo -e "\nok, installed python-scipy, continuing...\n"
# add scipy to the venv
mkdir ~/venv_PROJECT/lib/python2.7/site-packages/scipy/
ln -s /usr/lib/python2.7/dist-packages/scipy/* ~/venv_PROJECT/lib/python2.7/site-packages/scipy/
# add numpy to the venv
mkdir ~/venv_PROJECT/lib/python2.7/site-packages/numpy/
ln -s /usr/lib/python2.7/dist-packages/numpy/* ~/venv_PROJECT/lib/python2.7/site-packages/numpy/
# add PIL to the venv
mkdir ~/venv_PROJECT/lib/python2.7/site-packages/PIL/
ln -s /usr/lib/python2.7/dist-packages/PIL/* ~/venv_PROJECT/lib/python2.7/site-packages/PIL/
The compromise is that you won't be able to use diferent versions among different virtual environments and you're tied to the version in the repo.
妥协是你不能在不同的虚拟环境中使用不同的版本,你将被绑定到repo中的版本。
A word of warning:
一个字的警告:
>>> import scipy
>>> scipy.__version__
'0.13.3'
>>> import numpy
>>> numpy.__version__
'1.8.2'
>>> from PIL import Image
>>> Image.VERSION
'1.1.7'
#1
99
One solution is to temporarily enable swap on your micro instance. As described at this SO post, enable 1gb swap via:
一种解决方案是在您的微实例上临时启用交换。如本文所述,通过以下方式启用1gb交换:
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1
Once swap is on, install scipy via pip:
交换器打开后,通过pip安装scipy:
sudo apt-get install -y libatlas-base-dev gfortran python-dev build-essential g++
sudo pip install numpy
sudo pip install scipy
Once scipy successfully installs, you can disable it via:
一旦scipy成功安装,您可以通过以下方式禁用它:
sudo swapoff /var/swap.1
sudo rm /var/swap.1
#2
25
This worked for me:
这工作对我来说:
pip --no-cache-dir install scipy
See:
看到的:
-
Memory error while using pip install Matplotlib
使用pip安装Matplotlib时内存错误
https://github.com/pypa/pip/blob/9a23d4ed119327d3b823ec223aaead90964bac58/pip/basecommand.py#L56-L63
https://github.com/pypa/pip/blob/9a23d4ed119327d3b823ec223aaead90964bac58/pip/basecommand.py L56-L63
-
https://github.com/pypa/pip/blob/28cca11e284b37cc2c7977fd25be6f494adda9d3/src/pip/_internal/download.py L359-L367
note:
注意:
- works for other service providers, hardware, VMs, and containers.
- 适用于其他服务提供者、硬件、vm和容器。
- if RAM allocation size of 1GB
- 如果RAM分配大小为1GB。
- just calculate the diff between the cached directory memory usage and available ram
- 只需计算缓存的目录内存使用和可用ram之间的差异
#3
8
Yes, 512MB is not enough for compiling that C++ file.
是的,512MB对于编译c++文件来说是不够的。
Your best option is to build Scipy as a binary package (bdist, or eggs, or, more modern wheels) e.g. via python setupegg.py bdist_egg
on a different machine with compatible environment. For instance, use a similar Linux version to the EC2 instance in a virtual machine.
您最好的选择是将Scipy构建为一个二进制包(bdist或eggs,或更现代的车轮),例如通过python setupegg。在另一台具有兼容环境的机器上运行的py bdist_egg。例如,在虚拟机中使用与EC2实例相似的Linux版本。
In general, it's good to remember that when pip
installs packages, it compiles source files. If the package is not tiny, this is inefficient and it's better to use binary packages. The wheel
package format is supposed to play well together with pip.
通常,最好记住,当pip安装包时,它会编译源文件。如果包不是很小,那么这是低效的,最好使用二进制包。轮包格式应该与pip配合得很好。
#4
2
for me the error was slightly different.
对我来说,这个错误有点不同。
Blas (http://www.netlib.org/blas/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [blas]) or by setting
the BLAS environment variable.
----------------------------------------
Cleaning up...
Command /home/kdixit/pyvirt/bin/python -c "import setuptools;__file__='/home/kdixit/pyvirt/build/scipy/setup.py';exec(compile(open(__file__).read().replace('\r\n
Thus I had to install
因此我不得不安装
sudo apt-get install libblas-dev
and then it worked.
然后它工作。
#5
1
I was getting an out of virtual memory error during the scipy
compilation on a t2.micro
, I think numpy
compiled just fine. Anyway, I guess that Dolan Antenucci's answer would fix my issue, but instead I went another route, a compromise, which does work.
在t2的scipy编译过程中,我得到了一个虚拟内存错误。微,我觉得numpy编译得很好。不管怎么说,我想多兰·安图西的回答会解决我的问题,但我走了另一条路,一个妥协,这是可行的。
I'm running an Ubuntu
instance so keep that in mind.
我正在运行一个Ubuntu实例,所以请记住这一点。
sudo apt-get -y install python-scipy && echo -e "\nok, installed python-scipy, continuing...\n"
# add scipy to the venv
mkdir ~/venv_PROJECT/lib/python2.7/site-packages/scipy/
ln -s /usr/lib/python2.7/dist-packages/scipy/* ~/venv_PROJECT/lib/python2.7/site-packages/scipy/
# add numpy to the venv
mkdir ~/venv_PROJECT/lib/python2.7/site-packages/numpy/
ln -s /usr/lib/python2.7/dist-packages/numpy/* ~/venv_PROJECT/lib/python2.7/site-packages/numpy/
# add PIL to the venv
mkdir ~/venv_PROJECT/lib/python2.7/site-packages/PIL/
ln -s /usr/lib/python2.7/dist-packages/PIL/* ~/venv_PROJECT/lib/python2.7/site-packages/PIL/
The compromise is that you won't be able to use diferent versions among different virtual environments and you're tied to the version in the repo.
妥协是你不能在不同的虚拟环境中使用不同的版本,你将被绑定到repo中的版本。
A word of warning:
一个字的警告:
>>> import scipy
>>> scipy.__version__
'0.13.3'
>>> import numpy
>>> numpy.__version__
'1.8.2'
>>> from PIL import Image
>>> Image.VERSION
'1.1.7'