wings-easy


Namewings-easy JSON
Version 0.7 PyPI version JSON
download
home_pagehttps://github.com/5hmlA/PyTools
Summarypython library for easier develop
upload_time2025-08-01 04:07:44
maintainerNone
docs_urlNone
author5hmlA
requires_python>=3.6
licenseMIT Licence
keywords easy helpers
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ## PyCharm 自动生成 requirements.txt

> 使用Python打开自己的工程,然后点击Tools,最后点击Sync Python Requirements
>
> **pip install -r requirements.txt** 

### 其他注意事项:

 - 确保 requirements.txt 文件位于项目的根目录。
 - 在提交代码到版本控制系统之前,更新 requirements.txt 文件。
 - 在使用 pip install -r requirements.txt 安装依赖项时,确保使用与项目环境匹配的 Python 版本。

# 打包执行以下命令

### **```pyinstaller -n [your_exe_name] -F -w -i [your_ico] [your_main].py```** 

会根据打包指定的py文件解析所有依赖自动打包所有依赖文件,并生成一个可执行文件。
>--hidden-import 设置导入要动态加载的类 因为没被引用 所以不会导入需要手动设置
>
>上述命令中的选项说明:
>
>-n NAME, --name NAME: 可执行文件名称。
>
>-F, --onefile: 将整个项目打包为一个单独的可执行文件。
>
>-w, --windowed, --noconsole: 隐藏控制台窗口,将打包的应用程序显示为GUI应用程序。
>

# 打包报错排查

- ### <span style="color: red;">无法将“pyinstaller”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。</span>

  > 解决方案: 安装 PyInstaller
  >
  > pip install PyInstaller
  >
  > pyinstaller --name=<your_exe_name> --onefile --windowed --add-data "<your_data_folder>;<your_data_folder>" <your_script_name>.py


- ### <span style="color: red;">win32ctypes.pywin32.pywintypes.error: (225, 'EndUpdateResourceW', '无法成功完成操作,因为文件包含病毒或潜在的垃圾软件。</span>

  > 不使用-w --noconsole的命令打包隐藏命令行窗口时,是正常的,
  >
  > 但是使用-w或者--noconsole就会报错win32ctypes.pywin32.pywintypes.error: (225, '', '无法成功完成操作,因为文件包含病毒或潜在的垃圾软件。')
  >
  > 解决方案: 降级 PyInstaller, 安装6.2.0重新打包即可
  > 
  > pip install pyinstaller==6.2.0

## requirements

> pip freeze > requirements.txt
>
> pip install -r requirements.txt

## 打包

> pyinstaller -n [your_exe_name] -F -w -i [your_ico] [your_main_].py
>
> pyinstaller --onefile --add-data "[your_folder]/*.py;[your_folder]" [your_main_].py
>
> pyinstaller --onefile --add-data "[your_folder];[your_folder]" [your_main_].py
>
> pyinstaller --onefile --hidden-import=[your_module] [your_main_].py

## `--hidden-import` 与 `--add-data` 的区别

在使用 PyInstaller 打包 Python 应用程序时,`--hidden-import` 和 `--add-data` 是两个用途不同的参数,具体区别如下:

### `--hidden-import`

- **用途**:用于显式指定那些**未在代码中直接引用**但运行时需要的模块。
- **场景**:当代码中通过字符串导入模块(如 `importlib.import_module()`)或动态导入某些模块时,PyInstaller
  可能无法自动检测到这些依赖项,这时需要使用 `--hidden-import` 手动添加这些模块。
- **示例**:`--hidden-import=module_name`

### `--add-data`

- **用途**:用于将**非 Python 文件**(如图片、配置文件、资源文件等)打包进最终的可执行文件。
- **场景**:当项目依赖外部文件(如图标、JSON 配置文件、模板等)时,使用 `--add-data` 指定这些文件或目录,确保它们在运行时可被访问。
- **格式**:`--add-data "<source_path>;<destination_subdir>"`**<span style="background-color: green">(Windows
  上使用分号 `;` 分隔,Linux/macOS 使用冒号 `:`)</span>**
- **示例**:`--add-data "resources;resources"` 表示将本地的 `resources` 文件夹打包到可执行文件中的 `resources` 子目录中。

### 总结对比

| 参数                | 用途                | 示例用法                               |
|-------------------|-------------------|------------------------------------|
| `--hidden-import` | 添加运行时需要但未被自动检测的模块 | `--hidden-import=my_module`        |
| `--add-data`      | 添加非代码资源文件         | `--add-data "resources;resources"` |

: 添加项目资源,支持文件夹和文件,前面是资源路径,后面是输出路径,用分号进行分割。
>
>-i <FILE.ico>, --icon <FILE.ico> :  指定icon
>
>执行上述命令后,会在项目目录下生成一个.spec文件,这个文件会告诉PyInstaller如何将项目打包成exe文件。

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/5hmlA/PyTools",
    "name": "wings-easy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "easy, helpers",
    "author": "5hmlA",
    "author_email": "gene.jzy@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/46/28/63b4a898d02f9ebeddc6a950d271d74a507035853f48ec3661c50b802b23/wings_easy-0.7.tar.gz",
    "platform": null,
    "description": "## PyCharm \u81ea\u52a8\u751f\u6210 requirements.txt\n\n> \u4f7f\u7528Python\u6253\u5f00\u81ea\u5df1\u7684\u5de5\u7a0b\uff0c\u7136\u540e\u70b9\u51fbTools\uff0c\u6700\u540e\u70b9\u51fbSync Python Requirements\n>\n> **pip install -r requirements.txt** \n\n### \u5176\u4ed6\u6ce8\u610f\u4e8b\u9879\uff1a\n\n - \u786e\u4fdd requirements.txt \u6587\u4ef6\u4f4d\u4e8e\u9879\u76ee\u7684\u6839\u76ee\u5f55\u3002\n - \u5728\u63d0\u4ea4\u4ee3\u7801\u5230\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u4e4b\u524d\uff0c\u66f4\u65b0 requirements.txt \u6587\u4ef6\u3002\n - \u5728\u4f7f\u7528 pip install -r requirements.txt \u5b89\u88c5\u4f9d\u8d56\u9879\u65f6\uff0c\u786e\u4fdd\u4f7f\u7528\u4e0e\u9879\u76ee\u73af\u5883\u5339\u914d\u7684 Python \u7248\u672c\u3002\n\n# \u6253\u5305\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\n\n### **```pyinstaller -n [your_exe_name] -F -w -i [your_ico] [your_main].py```** \n\n\u4f1a\u6839\u636e\u6253\u5305\u6307\u5b9a\u7684py\u6587\u4ef6\u89e3\u6790\u6240\u6709\u4f9d\u8d56\u81ea\u52a8\u6253\u5305\u6240\u6709\u4f9d\u8d56\u6587\u4ef6\uff0c\u5e76\u751f\u6210\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u3002\n>--hidden-import \u8bbe\u7f6e\u5bfc\u5165\u8981\u52a8\u6001\u52a0\u8f7d\u7684\u7c7b \u56e0\u4e3a\u6ca1\u88ab\u5f15\u7528 \u6240\u4ee5\u4e0d\u4f1a\u5bfc\u5165\u9700\u8981\u624b\u52a8\u8bbe\u7f6e\n>\n>\u4e0a\u8ff0\u547d\u4ee4\u4e2d\u7684\u9009\u9879\u8bf4\u660e\uff1a\n>\n>-n NAME, --name NAME: \u53ef\u6267\u884c\u6587\u4ef6\u540d\u79f0\u3002\n>\n>-F, --onefile: \u5c06\u6574\u4e2a\u9879\u76ee\u6253\u5305\u4e3a\u4e00\u4e2a\u5355\u72ec\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\n>\n>-w, --windowed, --noconsole: \u9690\u85cf\u63a7\u5236\u53f0\u7a97\u53e3\uff0c\u5c06\u6253\u5305\u7684\u5e94\u7528\u7a0b\u5e8f\u663e\u793a\u4e3aGUI\u5e94\u7528\u7a0b\u5e8f\u3002\n>\n\n# \u6253\u5305\u62a5\u9519\u6392\u67e5\n\n- ### <span style=\"color: red;\">\u65e0\u6cd5\u5c06\u201cpyinstaller\u201d\u9879\u8bc6\u522b\u4e3a cmdlet\u3001\u51fd\u6570\u3001\u811a\u672c\u6587\u4ef6\u6216\u53ef\u8fd0\u884c\u7a0b\u5e8f\u7684\u540d\u79f0\u3002\u8bf7\u68c0\u67e5\u540d\u79f0\u7684\u62fc\u5199\uff0c\u5982\u679c\u5305\u62ec\u8def\u5f84\uff0c\u8bf7\u786e\u4fdd\u8def\u5f84\u6b63\u786e\uff0c\u7136\u540e\u518d\u8bd5\u4e00\u6b21\u3002</span>\n\n  > \u89e3\u51b3\u65b9\u6848: \u5b89\u88c5 PyInstaller\n  >\n  > pip install PyInstaller\n  >\n  > pyinstaller --name=<your_exe_name> --onefile --windowed --add-data \"<your_data_folder>;<your_data_folder>\" <your_script_name>.py\n\n\n- ### <span style=\"color: red;\">win32ctypes.pywin32.pywintypes.error: (225, 'EndUpdateResourceW', '\u65e0\u6cd5\u6210\u529f\u5b8c\u6210\u64cd\u4f5c\uff0c\u56e0\u4e3a\u6587\u4ef6\u5305\u542b\u75c5\u6bd2\u6216\u6f5c\u5728\u7684\u5783\u573e\u8f6f\u4ef6\u3002</span>\n\n  > \u4e0d\u4f7f\u7528-w --noconsole\u7684\u547d\u4ee4\u6253\u5305\u9690\u85cf\u547d\u4ee4\u884c\u7a97\u53e3\u65f6\uff0c\u662f\u6b63\u5e38\u7684\uff0c\n  >\n  > \u4f46\u662f\u4f7f\u7528-w\u6216\u8005--noconsole\u5c31\u4f1a\u62a5\u9519win32ctypes.pywin32.pywintypes.error: (225, '', '\u65e0\u6cd5\u6210\u529f\u5b8c\u6210\u64cd\u4f5c\uff0c\u56e0\u4e3a\u6587\u4ef6\u5305\u542b\u75c5\u6bd2\u6216\u6f5c\u5728\u7684\u5783\u573e\u8f6f\u4ef6\u3002')\n  >\n  > \u89e3\u51b3\u65b9\u6848: \u964d\u7ea7 PyInstaller, \u5b89\u88c56.2.0\u91cd\u65b0\u6253\u5305\u5373\u53ef\n  > \n  > pip install pyinstaller==6.2.0\n\n## requirements\n\n> pip freeze > requirements.txt\n>\n> pip install -r requirements.txt\n\n## \u6253\u5305\n\n> pyinstaller -n [your_exe_name] -F -w -i [your_ico] [your_main_].py\n>\n> pyinstaller --onefile --add-data \"[your_folder]/*.py;[your_folder]\" [your_main_].py\n>\n> pyinstaller --onefile --add-data \"[your_folder];[your_folder]\" [your_main_].py\n>\n> pyinstaller --onefile --hidden-import=[your_module] [your_main_].py\n\n## `--hidden-import` \u4e0e `--add-data` \u7684\u533a\u522b\n\n\u5728\u4f7f\u7528 PyInstaller \u6253\u5305 Python \u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c`--hidden-import` \u548c `--add-data` \u662f\u4e24\u4e2a\u7528\u9014\u4e0d\u540c\u7684\u53c2\u6570\uff0c\u5177\u4f53\u533a\u522b\u5982\u4e0b\uff1a\n\n### `--hidden-import`\n\n- **\u7528\u9014**\uff1a\u7528\u4e8e\u663e\u5f0f\u6307\u5b9a\u90a3\u4e9b**\u672a\u5728\u4ee3\u7801\u4e2d\u76f4\u63a5\u5f15\u7528**\u4f46\u8fd0\u884c\u65f6\u9700\u8981\u7684\u6a21\u5757\u3002\n- **\u573a\u666f**\uff1a\u5f53\u4ee3\u7801\u4e2d\u901a\u8fc7\u5b57\u7b26\u4e32\u5bfc\u5165\u6a21\u5757\uff08\u5982 `importlib.import_module()`\uff09\u6216\u52a8\u6001\u5bfc\u5165\u67d0\u4e9b\u6a21\u5757\u65f6\uff0cPyInstaller\n  \u53ef\u80fd\u65e0\u6cd5\u81ea\u52a8\u68c0\u6d4b\u5230\u8fd9\u4e9b\u4f9d\u8d56\u9879\uff0c\u8fd9\u65f6\u9700\u8981\u4f7f\u7528 `--hidden-import` \u624b\u52a8\u6dfb\u52a0\u8fd9\u4e9b\u6a21\u5757\u3002\n- **\u793a\u4f8b**\uff1a`--hidden-import=module_name`\n\n### `--add-data`\n\n- **\u7528\u9014**\uff1a\u7528\u4e8e\u5c06**\u975e Python \u6587\u4ef6**\uff08\u5982\u56fe\u7247\u3001\u914d\u7f6e\u6587\u4ef6\u3001\u8d44\u6e90\u6587\u4ef6\u7b49\uff09\u6253\u5305\u8fdb\u6700\u7ec8\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002\n- **\u573a\u666f**\uff1a\u5f53\u9879\u76ee\u4f9d\u8d56\u5916\u90e8\u6587\u4ef6\uff08\u5982\u56fe\u6807\u3001JSON \u914d\u7f6e\u6587\u4ef6\u3001\u6a21\u677f\u7b49\uff09\u65f6\uff0c\u4f7f\u7528 `--add-data` \u6307\u5b9a\u8fd9\u4e9b\u6587\u4ef6\u6216\u76ee\u5f55\uff0c\u786e\u4fdd\u5b83\u4eec\u5728\u8fd0\u884c\u65f6\u53ef\u88ab\u8bbf\u95ee\u3002\n- **\u683c\u5f0f**\uff1a`--add-data \"<source_path>;<destination_subdir>\"`**<span style=\"background-color: green\">\uff08Windows\n  \u4e0a\u4f7f\u7528\u5206\u53f7 `;` \u5206\u9694\uff0cLinux/macOS \u4f7f\u7528\u5192\u53f7 `:`\uff09</span>**\n- **\u793a\u4f8b**\uff1a`--add-data \"resources;resources\"` \u8868\u793a\u5c06\u672c\u5730\u7684 `resources` \u6587\u4ef6\u5939\u6253\u5305\u5230\u53ef\u6267\u884c\u6587\u4ef6\u4e2d\u7684 `resources` \u5b50\u76ee\u5f55\u4e2d\u3002\n\n### \u603b\u7ed3\u5bf9\u6bd4\n\n| \u53c2\u6570                | \u7528\u9014                | \u793a\u4f8b\u7528\u6cd5                               |\n|-------------------|-------------------|------------------------------------|\n| `--hidden-import` | \u6dfb\u52a0\u8fd0\u884c\u65f6\u9700\u8981\u4f46\u672a\u88ab\u81ea\u52a8\u68c0\u6d4b\u7684\u6a21\u5757 | `--hidden-import=my_module`        |\n| `--add-data`      | \u6dfb\u52a0\u975e\u4ee3\u7801\u8d44\u6e90\u6587\u4ef6         | `--add-data \"resources;resources\"` |\n\n: \u6dfb\u52a0\u9879\u76ee\u8d44\u6e90\uff0c\u652f\u6301\u6587\u4ef6\u5939\u548c\u6587\u4ef6\uff0c\u524d\u9762\u662f\u8d44\u6e90\u8def\u5f84\uff0c\u540e\u9762\u662f\u8f93\u51fa\u8def\u5f84\uff0c\u7528\u5206\u53f7\u8fdb\u884c\u5206\u5272\u3002\n>\n>-i <FILE.ico>, --icon <FILE.ico> :  \u6307\u5b9aicon\n>\n>\u6267\u884c\u4e0a\u8ff0\u547d\u4ee4\u540e\uff0c\u4f1a\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u751f\u6210\u4e00\u4e2a.spec\u6587\u4ef6\uff0c\u8fd9\u4e2a\u6587\u4ef6\u4f1a\u544a\u8bc9PyInstaller\u5982\u4f55\u5c06\u9879\u76ee\u6253\u5305\u6210exe\u6587\u4ef6\u3002\n",
    "bugtrack_url": null,
    "license": "MIT Licence",
    "summary": "python library for easier develop",
    "version": "0.7",
    "project_urls": {
        "Homepage": "https://github.com/5hmlA/PyTools"
    },
    "split_keywords": [
        "easy",
        " helpers"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3a42cd79e71d004e1294a86d859cb6e6aea70948f22e56594ebf369f6453b970",
                "md5": "c48c7f58087cca0a3652f086c4c4c864",
                "sha256": "0e892fbdff224085d8acb57c110ad388b5059cefa6652541bc5a33a42f58daca"
            },
            "downloads": -1,
            "filename": "wings_easy-0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c48c7f58087cca0a3652f086c4c4c864",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 20453,
            "upload_time": "2025-08-01T04:07:43",
            "upload_time_iso_8601": "2025-08-01T04:07:43.516915Z",
            "url": "https://files.pythonhosted.org/packages/3a/42/cd79e71d004e1294a86d859cb6e6aea70948f22e56594ebf369f6453b970/wings_easy-0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "462863b4a898d02f9ebeddc6a950d271d74a507035853f48ec3661c50b802b23",
                "md5": "8de38b86c4a7ca400c25641794f848e1",
                "sha256": "975196e30f1a96a564ba8d5ad8a5c8a3c3bdd252f5e07cc804daf7c08bd0ded8"
            },
            "downloads": -1,
            "filename": "wings_easy-0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "8de38b86c4a7ca400c25641794f848e1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 19905,
            "upload_time": "2025-08-01T04:07:44",
            "upload_time_iso_8601": "2025-08-01T04:07:44.537402Z",
            "url": "https://files.pythonhosted.org/packages/46/28/63b4a898d02f9ebeddc6a950d271d74a507035853f48ec3661c50b802b23/wings_easy-0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-01 04:07:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "5hmlA",
    "github_project": "PyTools",
    "github_not_found": true,
    "lcname": "wings-easy"
}
        
Elapsed time: 3.00888s