1 下载软件
下载速度插件过慢
方法一
直接在命令行中指定源地址,如下:
pip install -i https://pypi.doubanio.com/simple/ 包名`
或者:
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple 包名`
以上两个源地址的下载速度都很快。
方法二
在配置文件中修改源地址,如下:
建一个 ~/.pip/pip.conf文件,添加内容如下
[global]
index-url = http://b.pypi.python.org/simple
[install]
use-mirrors = true
mirrors = http://b.pypi.python.org
</pre>
也可以在[global]中加入timeout = 6000,以防止网速过慢情况下包下载不完
2 安装
1 安装Python
不需要自定义的话,可以选择inStall nOW
本人选择Cunstonzie installation





2 在系统环境变量中配置(记住自己的安装路径)

3 安装pycharm-community-2022.3.3






4 更新pip
命令:python.exe -m pip install --upgrade pip

参数介绍
pyinstaller -F -w main.py -i main.ico --workpath build路径 --distpath exe打包路径 -n exe名字
参数 | 介绍 |
---|---|
-F | --onefile 打包一个单个文件,如果你的代码都写在了一个py文件的话,可以使用这个命令,如果是多个py文件,就别用 |
-D | --onedir 打包多个文件,在dist中生成很多依赖文件,适合以框架的形式编写工具代码,代码易于维护 |
-a | --ascii 不包含unicode编码的支持(包括默认值:如果可用) |
-c | --console 使用控制台子系统执行(默认),只对windows有效 |
-w | --windowed, --noconsole 使用windows子系统执行,当程序启动的时候不会打开命令行(只对windows有效) |
-i | --icon=<File.ico>将file.ico添加为打包的exe文件的图表,只对windows系统有效 |
--icon=<File.exe,n>将file.exe的第n个图标添加为可执行文件的资源,只对windows系统有效 | |
-n | --name=Name 可选的项目,生成的.spec文件的名字和exe名字 |
-p | 设置导入路径(和使用PYTHONPATH效果相似),可以使用路径分隔符(windows使用分好,linux使用冒号),制定多个目录的时候可以指定多个-p参数来设置,让pyinstaller自己去找程序的资源 |
--key KEY | 用于加密Python字节码的密钥 |
--add-data | 可以将一些非二进制文件添加到exe文件中进行打包,参数为格式为static;static |
--distpath | 指定打包后的程序存放目录,exe文件默认存放在当前目录下的dist目录中 |
--workpath | 为输出的所有临时文件指定存放目录,默认为当前目录下的build目录 |
5 打包
安装 pip install Pyinstaller

验证

参数设置
打开要打包的项目

打包命令,可以把项目的improt 的导入的lib 给打包到项目
pyinstaller -D main.py -p D:\python\PythonProject\one\venv\Lib\site-packages
6 Pycharm 使用
创建项目

项目导入的lib 所在地

网友评论