zoukankan      html  css  js  c++  java
  • 把Python项目打包成exe文件和pip国内镜像的安装

    前言:

    用pip管理工具安装库文件时,默认使用国外的源文件,因此在国内的下载速度会比较慢,可能只有50KB/s。幸好,国内的一些顶级科研机构已经给我们准备好了各种镜像,下载速度可达2MB/s。
    其中,比较常用的国内镜像包括:
    
    (1)阿里云 http://mirrors.aliyun.com/pypi/simple/2)豆瓣http://pypi.douban.com/simple/3)清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/4)中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/5)华中科技大学http://pypi.hustunique.com/
    
    注意:新版ubuntu要求使用https源。
    
    设置方法:(以清华镜像为例,其它镜像同理)
    (1)临时使用:
    可以在使用pip的时候,加上参数-i和镜像地址(如
    https://pypi.tuna.tsinghua.edu.cn/simple),
    例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pandas,这样就会从清华镜像安装pandas库。
    2)永久修改,一劳永逸:
    (a)Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)
    内容如下:
    
    [global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple
    [install]
    trusted-host = https://pypi.tuna.tsinghua.edu.cn
    
    (b) windows下,直接在user目录中创建一个pip目录,如:C:Usersxxpip,然后新建文件pip.ini,即 %HOMEPATH%pippip.ini,在pip.ini文件中输入以下内容(以豆瓣镜像为例):
    
    [global]
    index-url = http://pypi.douban.com/simple
    [install]
    trusted-host = pypi.douban.com

    官网:http://www.pyinstaller.org

    1. 安装 pyinstaller

    pip install pyinstaller

    2.检查安装成功的版本

    pyinstaller -v

    3. 执行生成exe

    pyinstaller start.py

    如果成功的话,会在当前目录生成一个build和dist的文件夹,大家打开文件夹dist可以看到与start同名的目录,start文件夹即是项目打包生成的文件夹,打开start文件夹里面有个与start同名的start.exe即是启动文件。

    根据文字内容播放相关语音

    1.安装pywin32插件

    pip install pywin32
    # pip install pyttsx3

    2. 编写测试代码:

    import pythoncom
    from win32com import client
    
    pythoncom.CoInitialize()
    engine = client.Dispatch("SAPI.SpVoice")
    engine.Speak('Hello World')

    3. 运行

  • 相关阅读:
    openwrt 相关文章
    负载均衡相关文章
    Today's Progress
    Rodrigues formula is beautiful, but uneven to sine and cosine. (zz Berkeley's Page)
    Camera Calibration in detail
    Fundamental Matrix in Epipolar
    Camera Calibration's fx and fy do Cares in SLAM
    FilterEngine::apply
    FilterEngine 类解析——OpenCV图像滤波核心引擎(zz)
    gaussBlur
  • 原文地址:https://www.cnblogs.com/jiangxiaobo/p/12258751.html
Copyright © 2011-2022 走看看