python 常用技巧

1、 打印当前python 的安装包位置

  python3:

  python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"

  python2:

  python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"

2、安装pip

2.1(yum安装):
1、首先安装epel扩展源:
[root@localhost ~]#  yum -y install epel-release
如果没有安装epel扩展源而直接安装python-pip时,会出现找到该软件包的错误。
这是因为像centos这类衍生出来的发行版,他们的源有时候内容更新的比较滞后,或者说有时候一些扩展的源根本就没有。
2、安装pip
[root@localhost ~]#  yum -y install  python-pip
3、更新pip
[root@localhost ~]#  pip install --upgrade pip
4、安装后清除cache
[root@localhost ~]#  yum clean all

2.2(源码安装):
[root@localhost ~]#  wget --no-check-certificate https://github.com/pypa/pip/archive/1.5.5.tar.gz
注意:wget获取https的时候要加上:--no-check-certificate
[root@localhost ~]#  tar zvxf 1.5.5.tar.gz    #解压文件
[root@localhost pip-1.5.5]#  cd pip-1.5.5/
[root@localhost pip-1.5.5]#  python setup.py install

2.3(get-pip安装):
[root@localhost ~]#  curl https://bootstrap.pypa.io/get-pip.py | python

 

 

指定ip端口 启动jupyter notebook

jupyter notebook --no-browser --port 6000 --ip=192.168.1.103

 https://blog.csdn.net/hotpotbo/article/details/79130899

 

 

for--break--else

for i in range(6):
   if i == 5:
       print(3)
       break
else:
    print("did not break loop")

 

 

https://segmentfault.com/a/1190000012923757

 yum -y groupinstall development 

yum -y install zlib-devel

 

yum install -y ncurses-libs zlib-devel mysql-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

 

安装Python3.7

Detailed steps to install Python 3.7 in CentOS or any redhat linux machine:

  1. Download Python from https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
  2. Extract the content in new folder
  3. Open Terminal in the same directory
  4. Run below code step by step :
sudo yum -y install gcc gcc-c++ 
sudo yum -y install zlib zlib-devel
sudo yum -y install libffi-devel 
./configure
make
make install
posted @ 2018-10-10 16:22  Ray_lei  阅读(366)  评论(0编辑  收藏  举报