>>配置网络
TYPE=Ethernet #网卡类型
DEVICE=eth0 #网卡接口名称 ONBOOT=yes #系统启动时是否自动加载 BOOTPROTO=static #启用地址协议 --static:静态协议 --bootp协议 --dhcp协议 IPADDR=192.168.1.11 #网卡IP地址 NETMASK=255.255.255.0 #网卡网络地址 GATEWAY=192.168.1.1 #网卡网关地址 DNS1=10.203.104.41 #网卡DNS地址 HWADDR=00:0C:29:13:5D:74 #网卡设备MAC地址 BROADCAST=192.168.1.255 #网卡广播地址
/etc/init.d/network reload
--启动; ifup,ifdown;service network xxx;
netstat -r //查看路由网关等信息;
>>yum--本地源--so
mount -o loop /dev/cdrom /media/CentOS
baseurl=file:///media/CentOS/
>>安装vim,gcc,gcc-c++,
--出现以下错误,
Python build finished, but the necessary bits to build these modules were not found
安装yum install, 安装开发包;
readline-devel sqlite-devel bzip2-devel.i686 openssl-devel.i686 gdbm-devel.i686 libdbi-devel.i686 ncurses-libs zlib-devel.i686
>>
1.CentOs 安装python 2.7
yum groupinstall "Development tools" yum install zlib-devel libxml2-devel libxslt-devel openssl openssl-devel zlib mysql-devel libffi-devel postgresql-devel
wget http://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz tar xf Python-2.7.10.tgz cd Python-2.7.10 ./configure --prefix=/usr/local/python2710 make && make altinstall
2,升级安装
mkdir -p ~/Env/python; cd ~/Env/python # 创建个目录
wget --no-check-certificate https:
//www.python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
tar Jxvf Python-
2.7
.
6
.tar.xz
cd Python-
2.7
.
6
./configure --prefix=/usr/local/py-
2.7
.
6
#
"./configure -h"
查看帮助
make # 报模块缺失时,有需要的安装后重make
# issue: INFO: Can't locate Tcl/Tk libs and/or headers
# Python build finished, but the necessary bits to build these modules were not found:
# ...
# 注
1
:zlib必要,之后安装setuptools要用。见
"安装setuptools"
。
# 注
2
:openssl必要,之后pip要用。见
"安装pip"
。
# 注
3
:bzip2也最好加,执行
"yum install bzip2 bzip2-devel -y"
。
make install /make altinstall
# 建立软链接,默认指向Python2.
7
mv /usr/bin/python /usr/bin/python2.
6.6
ln -s /usr/local/py-
2.7
.
6
/bin/python2.
7
/usr/bin/python
python -V # Python
2.7
.
6
# yum不兼容Python2.
7
,需要指定为原版本
vi /usr/bin/yum
/usr/libexec/urlgrabber-ext-down (cent7)# 将
"!/usr/bin/python"
改为
"!/usr/bin/python2.6.6";
# ibus也不兼容Python2.
7
,需要修改
# 将
"exec python"
改为
"exec python2.6.6"
ll /usr/bin | grep python # 确认下python2.
6.6
vi /usr/bin/ibus-setup # 修改
vi /usr/libexec/ibus-ui-gtk # 修改
reboot # 可能需要重启
3, 安装setup tools;
cd ~/Env/python
wget http:
//pypi.douban.com/packages/source/s/setuptools/setuptools-3.3.tar.gz # 豆瓣源
tar zxvf setuptools-
3.3
.tar.gz
cd setuptools-
3.3
python setup.py build
sudo python setup.py install
# 或者用ez_setup.py,同样改为豆瓣源
# wget https:
//bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
# python ez_setup.py --download-base http:
//pypi.douban.com/packages/source/s/setuptools/
# 缺少zlib,安装setuptools时出错。
# issue: RuntimeError: Compression requires the (missing) zlib module
yum install zlib zlib-devel -y
# 重make Python2.
7
再安装
cd ../Python-
2.7
.
6
make # 这时才注意先前make时缺了好多模块
make install
pkg_resources.DistributionNotFound: The ‘setuptools==0.9.8‘ distribution was not found,重新安装python的distribution-0.6.49(0.7.3的会报错)
tar -zxvf distribute-0.6.49.tar.gz cd distribute-0.6.49 python setup.py install
# 环境变量
vi /etc/profile
# 添加如下内容:
# PY_HOME=/usr/local/python2.7.8
# export PATH=$PY_HOME/bin:$PATH
source /etc/profile # 当前终端生效,reboot后才会完全生效
echo $PATH
4.安装pip
easy_install -i http:
//pypi.douban.com/simple pip
# 缺少ssl模块,pip使用时出错
# issue: ImportError: cannot
import
name HTTPSHandler
yum install openssl openssl-devel -y
make # Python-
2.7
.
6
目录
make install
# No module named 'pip._vendor.requests'
# 配置pip为豆瓣源
mkdir ~/.pip # ls或ll -a 查看隐藏内容
vi ~/.pip/pip.conf
# 添加如下内容:
# [global]
# index-url = http:
//pypi.douban.com/simple
5,安装virtual -env
su
pip install virtualenv
pip install virtualenvwrapper
6,virtualenv使用
virtualenv ENV
cd ENV
source ./bin/activate
--Virtaulenvwrapper
7.python---解决“Unable to find vcvarsall.bat”错误
yum install openldap ldap openldap-devel
今天在安装reportlab时老是发生Unable to find vcvarsall.bat的错误,上网找了一下,在eddsn找到了“Unable to find vcvarsall.bat” error when trying to install rdflib这么一篇文章,解决了问题。方法如下: 首先安装MinGW,在MinGW的安装目录下找到bin的文件夹,找到mingw32-make.exe,复制一份更名为make.exe; 把MinGW的路径添加到环境变量path中,比如我把MinGW安装到D:\MinGW\中,就把D:\MinGW\bin添加到path中; 打开命令行窗口,在命令行窗口中进入到要安装代码的目录下; 输入如下命令就可以安装了。 setup.py install build --compiler=mingw32
如果安装了VS2010或是VS2012可以使用下面的方法解决: If you have Visual Studio 2010 installed, execute > SET VS90COMNTOOLS=%VS100COMNTOOLS% or with Visual Studio 2012 installed > SET VS90COMNTOOLS=%VS110COMNTOOLS% python 2.7在setup的时候查找的是VS2008编译的。
8.python shell 后退,箭头等键无法使用;
yum install readline-devel
pip3 install readline
9.wheel方式安装应用,pip install x.whl
windows 下安装,VCForPython27
10.ipython notebook
pip install ipython,
pip install pyreadline , --on windows.
pip install pyzmq, --zeromq
--安装Tornado
--安装MathJax
from IPython.external.mathjax import install_mathjax install_mathjax()
//出错,手工从github下载,并解压到这里;~/.ipython/nbextensions/mathjax/...
from IPython.external.mathjax import install_mathjax
install_mathjax()
from IPython.display import LatexLatex(r"$\sqrt{x^2+y^2}$")
--启动本地notebook
随便找一个shell,在windows里,最简单的cmd.exe就行,键入: ipython.exe notebook即可。
//出错,pip install jsonschema
//依然不行,无法创建notebook,使用 pip install
terminado
--terminal unvilabel, 使用菜单new >python2//
Shift-Enter 将运行此代码,代码中最后一个表达式的值将输出区域显示。如果希望屏蔽输出,可以在最后一条语句之后添加一个分号:”;”
此外,代码中还可以使用print语句在输出区域中显示信息
--远程访问notebook
如果需要远程访问,就稍微麻烦一点: 首先,需要建立一个server的config,通过在命令行键入: ipython profile create nbserver 然后,修改新建的profile,即ipython_notebook_config.py(命令行会有输出,告诉你生成的文件在哪里),默认的config文件都是被注释掉的,你需要至少修改如下的项: c = get_config() # Kernel config c.IPKernelApp.pylab = 'inline' # if you want plotting support always # Notebook config c.NotebookApp.certfile = u'/absolute/path/to/your/certificate/mycert.pem' c.NotebookApp.ip = '*' c.NotebookApp.open_browser = False c.NotebookApp.password = u'sha1:bcd259ccf...your hashed password here' # It's a good idea to put it on a known, fixed port c.NotebookApp.port = 9999 但是,你需要注意的是,我们还没有mycert.pem,这个也很简单,使用openssl生成一个就行,如果你手头有linux机器的话就极其简单了: $ openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem 再接着,需要生成一串哈希后的密钥,随便开一个IPython的shell键入: In [1]: from IPython.lib import passwd In [2]: passwd() 设定你的密码即可(现在0.13版还不支持多人的notebook,因此只能单用户使用,只支持一个密码罢了,多用户功能处在开发中)。 好了,现在启动你的public的IPython notebook吧: ipython notebook --profile=nbserver 然后你就可以在浏览器里远程访问你的IPython notebook了
11,python windows 下安装各种包
http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy
来源:https://www.cnblogs.com/totoros/p/4179986.html