Linux 64位下一键安装scipy等科学计算环境

时间:2024-01-11 12:14:38

Linux 64位下一键安装scipy等科学计算环境

采用scipy.org的各种方法试过了,安装还是失败。找到了一键式安装包Anaconda,基本python要用到的库都齐了,而且还可以选择安装到其他目录下。

Anaconda is an easy-to-install free package manager, environment manager, Pythondistribution, and collection of over 720 open source packages offering free community support.

https://docs.continuum.io/anaconda/index

安装这个自动安装下面的机器学习算法包:

sciki-learn

  • Simple and efficient tools for data mining and data analysis
  • Accessible to everybody, and reusable in various contexts
  • Built on NumPy, SciPy, and matplotlib
  • Open source, commercially usable - BSD license

http://scikit-learn.org/stable/

1 安装 anaconda2

我选择python2.7的Linux安装包,安装的目录是:

/opt/anaconda2

一直使用的是python2.7.x,于是下载下面的包:

$ nohup wget -c http://repo.continuum.io/archive/Anaconda2-4.0.0-Linux-x86_64.sh &

按国内的网速,基本下一夜吧!也可以到我的FTP上下载:

$ wget ftp://pub:pub@pepstack.com/tarball/Anaconda2-4.0.0-Linux-x86_64.tgz

下载后解压安装。不解释。

# bash Anaconda2-4.0.0-Linux-x86_64.sh

安装完毕后执行一下:

# cd /opt/anaconda2/bin
# ./python

输出:

Python 2.7.11 |Anaconda 4.0.0 (64-bit)| (default, Dec  6 2015, 18:08:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
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
>>> import numpy
>>> import matplotlib

>>> import sklearn

>>> import mysql.connector
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named mysql.connector
>>> import theano
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named theano

./pip install --upgrade pip
./pip install theano

2 解决mysql.connector错误的问题

./pip install $pkg 查看哪些包$pkg可用:

https://docs.continuum.io/anaconda/pkg-docs

./pip install mysql-connector-python

失败!

./pip install mysql-python

失败!

于是手工安装:

# cd /opt/anaconda2/pkgs
# wget ftp://pub:pub@pepstack.com/tarball/mysql-connector-python-2.1.1.tar.gz
# tar -zxf mysql-connector-python-2.1.1.tar.gz
# cd mysql-connector-python-2.1.1
# ../../bin/python setup.py build
# ../../bin/python setup.py install
# cd /opt/anaconda2/bin
# python -c "import mysql.connector"

成功!

3 安装 python-inotify

# cd /opt/anaconda2/pkgs
# wget --no-check-certificate https://pypi.python.org/packages/source/p/pathlib/pathlib-1.0.1.tar.gz
# wget ftp://pub:pub@pepstack.com/prepare/JanKanis-python-inotify.tar.gz

(解压略)

# cd /opt/anaconda2/pkgs/pathlib-1.0.1
# ../../bin/python setup.py build
# ../../bin/python setup.py install
# cd /opt/anaconda2/pkgs/JanKanis-python-inotify
# ../../bin/python setup.py build
# ../../bin/python setup.py install
# cd /opt/anaconda2/bin
# python -c "import inotify"

成功!

4 安装 google tensor

TensorFlow is an Open Source Software Library for Machine Intelligence

下载CPU版本:

# wget http://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_CONTAINER_TYPE=CPU,TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON2,label=cpu-slave/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-0.8.0-cp27-none-linux_x86_64.whl

或者:

# wget ftp://pub:pub@pepstack.com/tarball/tensorflow-0.8.0-cp27-none-linux_x86_64.whl

然后安装:

$ sudo /opt/anaconda2/bin/pip install /path/to/tensorflow-0.8.0-cp27-none-linux_x86_64.whl

测试:

$ /opt/anaconda2/bin/python -c "import tensorflow"