请选择 进入手机版 | 继续访问电脑版
用户
 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
查看: 621|回复: 0

python安装和升级 以及车牌训练,opencv 安装 ubuntu安装

[复制链接]

930

主题

935

帖子

3992

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
3992
发表于 2018-1-10 15:14:03 | 显示全部楼层 |阅读模式
svn up --force

python

setuptools 28.8.0
wget https://bootstrap.pypa.io/ez_setup.py -O - | python

wget https://pypi.python.org/packages ... 19497f01a4ba69d63c9
python setup.py install
pip (9.0.1)

rpm -qa | grep ^tk
pip list//查看已经安装的库:

pip show Jinja2//查看某个库的信息:
pip list --outdated//获取过期的库:
pip list --outdated | grep Jinja2

pip install -U numpy==1.8
pip install -U scipy==0.9
pip install -U scikit-learn ==0.18

pip install queuelib


检测
python
import numpy
import scipy
import sklearn


强制安装
rpm -Uvh --replacepkgs *.rpm --force --nodeps
./configure --prefix=/usr/local/python2.6
make && make install
find / -name python2.6 -print
ln -sf  /usr/local/python2.6/bin/python2.6  /usr/bin/python2.6


rpm -aq|grep yum|xargs rpm -e --nodeps


断点续传测试
//app/Uploads/software/2016-10-11/t0118d819eb02ab3a88.jpg
//wget -S 2>&1 | grep 'Accept-Ranges'
//curl -i --range 0-9



path

D:\php-5.6.28-Win32-VC11-64\;C:\Users\lizhihua\AppData\Roaming\Composer\vendor\bin;D:\Users\Administrator\AppData\Local\Programs\Python\Python35\Scripts;



sqlmap 是一个开源的渗透测试工具,可以用来自动化的检测,利用SQL注入漏洞,获取数据库服务器的权限。它具有功能强大的检测引擎,针对各种不同类型数据库的渗透测试的功能选项,包括获取数据库中存储的数据,访问操作系统文件甚至可以通过外带数据连接的方式执行操作系统命令。
python sqlmap.py -u "http://10.10.152.48/toutiao/index.php?m=core&f=index&_su=wuzhicms" --batch



下载和安装Python

有个一个非常重要的步骤是我们使用的是make altinstall。如果使用make install,你将会看到在系统中有两个不同版本的Python在/usr/bin/目录中。这将会导致很多问题,而且不好处理。

https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz

wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tgz
tar zxvf Python-2.7.12.tgz
cd Python-2.7.12
./configure --prefix=/usr/local
./configure --enable-optimizations

重新编译python,因为报错是PyUnicodeUCS4_FromString,说明tensorflow是用UCS4编译的,而python是UCS2编译的:  
重新编译时设置unicode为ucs4  python2.7.11默认是使用UCS2

./configure --prefix=/usr/local/ --enable-unicode=ucs4
./configure --enable-optimizations

make && make altinstall
或者  make && make install && make clean
mv /usr/bin/python /usr/bin/python2.6.6
ln -sf /usr/local/bin/python2.7 /usr/bin/python

ln -sf /usr/local/bin/pip2.7 /usr/bin/pip


5、解决 yum 的问题
因为yum需要使用Python2.6.6的版本,现在 yum 应该不能干活了,还有设置一下yum相关的文件,这样执行yum相关的命令时才不会出错。
"vim /usr/bin/yum",修改第一句,替换成保留的2.6.6的版本:
!/usr/bin/python2.6.6
果然熟悉的 yum 界面出来了!


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


yum install -y zlib-devel bzip2-devel xz-libs xz wget git tar gcc gcc-c++ openssl openssl-devel pcre-devel python-devel libevent automake autoconf libtool make git
wget http://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz
tar -xvf Python-2.7.8.tar.xz
cd Python-2.7.8
./configure --prefix=/usr/local
make && make altinstall
mv /usr/bin/python /usr/bin/python2.6.6
ln -s /usr/local/bin/python2.7 /usr/bin/python

wget https://bootstrap.pypa.io/ez_setup.py -O - | python

wget https://pypi.python.org/packages ... 19497f01a4ba69d63c9
python setup.py install
pip (9.0.1)


wget --no-check-certificate https://pypi.python.org/packages ... ptools-1.4.2.tar.gz
tar -xvf setuptools-1.4.2.tar.gz
cd setuptools-1.4.2
python setup.py install

wget --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-6.0.7.tar.gz
tar zxvf pip-6.0.7.tar.gz
cd pip-6.0.7
python setup.py install


wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py



在使用 pip install scikit-learn 时报错,是安装依赖包scipy出错。
yum install -y blas-devel lapack-devel

pip install -U NumPy
pip install -U scipy
pip install -U scikit-learn


scikit-learn requires:

Python (>= 2.6 or >= 3.3)
NumPy (>= 1.6.1)
SciPy (>= 0.9)


http://www.scipy.org/install.html scipy的安装说明页面

python -c "import scikits.crab as scc; scc.test()"

ImportError: No module named crab

git clone https://github.com/muricoca/crab.git
python setup.py install


安装Matplotlib

yum install -y freetype*
yum install -y libpng-devel
git clone https://github.com/matplotlib/matplotlib.git
cd matplotlib
python setup.py build
python setup.py install

web服务 以及爬虫
pip install Scrapy
pip install tornado


1.4. Testing


测试需要的鼻子图书馆。安装后,可以测试包执行从外部源目录:

python -c "import scikits.crab as scc; scc.test()"
这应该给你一个大量输出(和一些警告)但最终应该完成一个文本相似:

Ran 101 tests in 10.920s
OK

否则请考虑发布一个问题到bug追踪器或邮件列表。


蟹也可以测试不包安装。这个你必须编译源代码原地从源目录:


python setup.py build_ext --inplace
使用nosetest测试现在可以运行:

nosetests scikits/crab/

nosetests -v sklearn

pip install -U numpy scipy matplotlib ipython jupyter pandas sympy nose


ModuleNotFoundError: No module named 'scikits.learn'

ImportError: cannot import name 'NUMPY_MKL'

yum install libsvm-dev libsvm3 python-libsvm

./allscp.sh /var/www/html/allscp.sh root 192.168.111.131 /var/www/html/scp/ lizhihua123 #单文件传输

http://www.liaoxuefeng.com/wiki/ ... 836bb0827607738d000


分词
pip install -U demjson
pip install -U flask
pip install -U flask-restful
pip install -U textrank4zh
pip install -U flask-script

/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT    添加 80 端口

/etc/rc.d/init.d/iptables save   保存

/etc/init.d/iptables status  查看状态

/etc/init.d/iptables restart  重启

chkconfig --level 35 iptables off   永久关闭

/sbin/iptables -I INPUT -p tcp --dport 32000 -j ACCEPT #开启8080端口  
/etc/rc.d/init.d/iptables save #保存配置  
/etc/rc.d/init.d/iptables restart #重启服务  


python webapi.py &
nohup python webapi.py &


也可以用这个命令查出某端口被哪个程序占用了:

lsof -i:端口号
然后把端口对应的进程关掉:

kill -9 [UID]


[python] pip 升级所有的包
pip 当前内建命令并不支持升级所有已安装的Python模块。

列出当前安装的包:

pip list
列出可升级的包:

pip list --outdate
升级一个包:

pip install --upgrade requests  // mac,linux,unix 在命令前加 sudo -H
升级所有可升级的包:

pip freeze --local | grep -v '^-e' | cut -d = -f 1  | xargs -n1 pip install -U
for i in `pip list -o --format legacy|awk '{print $1}'` ; do pip install --upgrade $i; done
pip默认源由于墙,所以速度很慢,可使用第三源提高速度:

vim ~/.pip/pip.conf
[global]
trusted-host = mirrors.aliyun.com
index-url = http://mirrors.aliyun.com/pypi/simple



http://ftp.de.debian.org/debian/ ... +6_4.7.2-5_i386.deb

yum whatprovides libstdc++.so.6
yum install -y libstdc++-4.4.7-18.el6.i686
strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX



了解到PIL模块是一个图像处理模块库,也没有深入了解,就想着安装上用着试试,结果就掉入了一个坑,话说自己选的路,流着泪也要走完。走完路后,记下这辛酸的过程,装一下。。。
如果已经出错,先卸载

pip uninstall PIL

下面介绍正规流程,先安装JPEG和FreeType库

yum install libjpeg-devel freetype-devel

然后在安装PIL的库,安装方法如下

pip install PIL --allow-external PIL --allow-unverified PIL

当然你也可以选择下载源码编译安装

版权声明:本文为米刀文原创文章,转载请标记出处,谢谢!

pip search PIL
pip install Pillow
pip install --upgrade IPython

pip --default-timeout=100 install -U pip
pip --default-timeout=100 install -U Keras
pip install --default-timeout=300 openCV-python
-i "https://pypi.doubanio.com/simple/"



pip install virtualenv #先安装这个 环境切换的东西
#virtualenv -h  #查看帮助


#virtualenv venv #创建虚拟环境的目录,名为venv,它包含了Python可执行文件和拷贝过来的pip 库(能安装需要的包到虚拟环境)

#(若省略名字将不创建目录,文件均直接放在当前目录)

virtualenv -p /usr/bin/python2.7 venv# -p选项 选择使用哪一版本的Python解释器
#--no-site-packages 选项 virtualenv 将不会包括物理机python环境安装的包(这在 virtualenv 1.7及之后是默认的)

source venv/bin/activate #激活刚才创建的虚拟环境
# deactivate #有必要时可关闭虚拟环境

pip install -r requirements.txt #安装项目需要的包


#pip list #查看 当前环境中所有包及各自的版本的列表。

#创建一个 requirements.txt 文件(包含了当前环境中所有包及各自的版本的简单列表)
#pip freeze > requirements.txt

#virtualenv --relocatable env
#打包虚拟环境env 。 可以解压到本机其他目录后直接使用


deactivate
#退出虚拟环境,回到正常shell

pip install --upgrade https://storage.googleapis.com/t ... cp35m-win_amd64.whl

pip list --outdated
pip install --upgrade SomePackage
升级所有可升级的包:
pip freeze --local | grep -v '^-e' | cut -d = -f 1  | xargs -n1 pip install -U
for i in `pip list -o --format legacy|awk '{print $1}'` ; do pip install --upgrade $i; done

vim ~/.pip/pip.conf
[global]
trusted-host = mirrors.aliyun.com
index-url = http://mirrors.aliyun.com/pypi/simple

    format=columns

    环境变量
    D:\Program Files (x86)\ImageMagick-7.0.7-Q16;D:\Program Files\ImageMagick-7.0.7-Q16;D:\mingw\bin;D:\Program Files (x86)\ImageMagick-6.9.9-Q16;D:\Program Files (x86)\ImageMagick-6.7.7-Q16;D:\Program Files (x86)\ImageMagick-6.8.4-Q16;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows7Master;D:\Program Files\TortoiseSVN\bin;C:\ProgramData\ComposerSetup\bin;%USERPROFILE%\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;D:\Program Files\WinPython-64bit-3.6.0.1Qt5\scripts;D:\phpStudy\MySQL\bin;D:\Program Files\TortoiseHg\;D:\Program Files\Redis\;D:\phpStudy\php\php-7.0.12-nts;D:\Program Files\nodejs\;D:\Program Files\Git\cmd;D:\Program Files (x86)\Tesseract-OCR;D:\Program Files\Mozilla Firefox;

    https://storage.googleapis.com/t ... ne-linux_x86_64.whl
    https://storage.googleapis.com/t ... ne-linux_x86_64.whl

    安装pyOpenSSL:

    yum -y install pyOpenSSL
    或者
    wget https://launchpad.net/pyopenssl/ ... OpenSSL-0.11.tar.gz
    python setup.py install



    Python 2.7

    CPU only:

    https://storage.googleapis.com/t ... ne-linux_x86_64.whl
    GPU support:

    https://storage.googleapis.com/t ... ne-linux_x86_64.whl


    sudo apt-get install openssh-server

    https://segmentfault.com/a/1190000007715243
    https://raw.githubusercontent.co ... _linux_20151201.tgz
    http://blog.csdn.net/cyn618/article/details/64494434
    https://opencv.org/opencv-3-4.html

    Ubuntu16.04 OpenCV Python开发环境搭建

    sudo su
    系统升级
    sudo apt-get update
    sudo apt-get upgrade
    sudo apt-get install build-essential cmake pkg-config
    sudo apt-get install libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev
    sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
    sudo apt-get install libxvidcore-dev libx264-dev
    sudo apt-get install libgtk-3-dev
    sudo apt-get install libatlas-base-dev gfortran
    sudo apt-get install python2.7-dev python3.5-dev
    安装python基础开发包
    sudo apt install -y python-dev python-pip python-nose gcc g++ git gfortran vim
    安装运算加速库
    sudo apt install -y libopenblas-dev liblapack-dev libatlas-base-dev

    sudo apt-get install python-pip python-dev
    pip install --upgrade  pip
    pip install tensorflow

    sudo pip install -U --pre pip setuptools wheel
    sudo pip install -U --pre numpy scipy matplotlib scikit-learn scikit-image
    sudo pip install -U --pre tensorflow-gpu
    sudo pip install -U --pre tensorflow ## CPU版本
    sudo pip install -U --pre keras
    apt-get install -y python-tk
    sudo pip install -U --pre h5py
    pip install -U --pre wxpy


    #pip install --ignore-installed --upgrade "https://github.com/lakshayg/tensorflow-build/raw/master/tensorflow-1.4.0-cp27-cp27mu-linux_x86_64.whl" --default-timeout=300


    >>> git clone https://github.com/fchollet/keras.git
    >>> cd keras/examples/
    >>> python mnist_mlp.py


    加速库cuDNN(可选)
    >>> sudo cp include/cudnn.h /usr/local/cuda/include/
    >>> sudo cp lib64/* /usr/local/cuda/lib64/
    >>> cd /usr/local/cuda/lib64
    >>> sudo ln -sf libcudnn.so.5.1.10 libcudnn.so.5
    >>> sudo ln -sf libcudnn.so.5 libcudnn.so
    >>> sudo ldconfig -v

    apt-get install -y liblapacke-dev checkinstall
    cd ~
    wget -O ippicv_linux_20151201.tgz https://raw.githubusercontent.co ... _linux_20151201.tgz

    wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.2.0.zip  
    unzip opencv.zip

    cp ~/ippicv_linux_20151201.tgz ~/opencv-3.1.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/ippicv_linux_20151201.tgz
    cp ~/ippicv_linux_20151201.tgz ~/opencv-3.2.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e/ippicv_linux_20151201.tgz

    cd opencv-3.2.0  
    mkdir build  
    cd build
    cmake -D CMAKE_BUILD_TYPE=RELEASE \
        -D CMAKE_INSTALL_PREFIX=/usr/local \
        -D INSTALL_PYTHON_EXAMPLES=ON \
        -D INSTALL_C_EXAMPLES=OFF \
        -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.2.0/modules \
        -D PYTHON_EXECUTABLE=~/.virtualenvs/cv/bin/python \
        -D WITH_OPENMP=ON \
        -D BUILD_EXAMPLES=ON ..

    cmake -D CMAKE_BUILD_TYPE=RELEASE \
        -D CMAKE_INSTALL_PREFIX=/usr/local \
        -D INSTALL_PYTHON_EXAMPLES=ON \
        -D INSTALL_C_EXAMPLES=OFF \
        -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules \
        -D PYTHON_EXECUTABLE=~/.virtualenvs/cv/bin/python \
        -D BUILD_EXAMPLES=ON ..
    make -j4
    sudo make install  
    sudo ldconfig

    安装 virtualenv
    sudo pip install virtualenv
    sudo rm -rf ~/get-pip.py ~/.cache/pip

    mkdir ~/.virtualenvs
    cd ~/.virtualenvs
    virtualenv cv -p python2
    pip install Keras

    ls -l /usr/local/lib/python2.7/site-packages/ | grep cv2.so
    cd ~/.virtualenvs/cv/lib/python2.7/site-packages/
    ln -sf /usr/local/lib/python2.7/site-packages/cv2.so cv2.so

    测试Python的OpenCV模块
    python -c "import cv2; print cv2.__version__"

    KERAS_BACKEND=tensorflow python -c "from keras import backend"

    sudo apt-get install nvidia-384 #can type nvidia then hit "tab" to view all available options
    sudo apt-get install cuda-8-0
    Reboot

    Run export LD_LIBRARY_PATH=/usr/local/cuda-8.0/extras/CUPTI/lib64LD_LIBRARY_PATH but replace /usr/local/cuda-8.0/extras/CUPTI/lib64 with the relevant output from echo $LD_LIBRARY_PATH


    python
    import tensorflow as tf
    hello = tf.constant('Hello, TensorFlow!')
    sess = tf.Session()
    print(sess.run(hello))


    https://github.com/zeusees/HyperLPR
    http://keras-cn.readthedocs.io/e ... as_linux/#3-cudacpu
    https://developer.nvidia.com/cud ... t_type=runfilelocal
    https://www.tensorflow.org/install/install_linux


    https://github.com/pageauc/opencv3-setup

    curl -L https://raw.github.com/pageauc/opencv3-setup/master/setup.sh | bash

    wget https://raw.github.com/pageauc/opencv3-setup/master/setup.sh
    chmod +x setup.sh
    ./setup.sh

    cd ~/opencv3-setup
    ./cv32-setup.sh


    pip list --outdated
    pip install --upgrade SomePackage
    升级所有可升级的包:
    pip freeze --local | grep -v '^-e' | cut -d = -f 1  | xargs -n1 pip install -U
    for i in `pip list -o --format legacy|awk '{print $1}'` ; do pip install --upgrade $i; done


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

返回顶部