简体   繁体   English

使用 cloudcraper 模块创建.exe (pyinstaller) 时出错

[英]Error creating .exe (pyinstaller) with cloudscraper module

I'm trying to create an.exe from my python script.我正在尝试从我的 python 脚本创建 an.exe。 The script uses the cloudscraper package.该脚本使用cloudscraper package。 When I create the.exe and I execute it, it shows the following error:当我创建 .exe 并执行它时,它显示以下错误:

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\...\\MEI1....\\cloudscraper\\user_agent\\browsers.json'

The error ONLY APPEARS WHEN I TRY TO EXECUTE THE.exe file.该错误仅在我尝试执行该.exe 文件时出现。

Why is this happening?为什么会这样? Is cloudscraper unavailable with pyinstaller? pyinstaller 无法使用 cloudcraper 吗?

The project structure looks like this:项目结构如下所示:

C:\Users\andre\OneDrive\Documentos\Programming\Python\Python3\proyect

proyect 
   |
   |______ main.py
   |
   |______ services
           |________ __init__.py
           |_______ main_service.py
           |_______ sql_service.py

This is very similar to my project structure since obviously, I cannot share the actual project structure of my project.这与我的项目结构非常相似,因为很明显,我无法分享我项目的实际项目结构。

Check this link: https://stackoverflow.com/a/64586862/14509818检查此链接: https://stackoverflow.com/a/64586862/14509818

or或者

Add this command while creating your exe.在创建 exe 时添加此命令。

--add-data "path_for_cloudscraper_folder;./cloudscraper/"

Replace path_for_cloudscraper_folder with the path of your cloudscraper folder.path_for_cloudscraper_folder替换为您的 cloudscraper 文件夹的路径。

You can explore and find your path of cloudscraper folder from pc or dowload it from github.您可以从 PC 浏览并找到您的 cloudcraper 文件夹路径,或从 github 下载。

Here ./cloudscraper/ is used to add cloudscraper folder in your root directory of output.这里./cloudscraper/用于在 output 的根目录下添加 cloudscraper 文件夹。 (expecting that it is searching in root directory for missing cloudscraper folder) (期望它在根目录中搜索丢失的 cloudcraper 文件夹)

Your.exe file is looking for browsers.json, but you didn't move that file to the same path as the.exe file.您的 .exe 文件正在寻找 browsers.json,但您没有将该文件移动到与 .exe 文件相同的路径。 Working with pyinstaller requires good experience handling relative and absolute paths, otherwise, you will face that kind of errors.使用 pyinstaller 需要有处理相对路径和绝对路径的良好经验,否则,您将面临此类错误。

If cloudscraper is not part of your project tree (maybe is a hidden import):如果 cloudcraper 不是您的项目树的一部分(可能是隐藏的导入):

  1. Try copy the folder named 'cloudscrapper' from here and paste it in the same path of your.exe file尝试从此处复制名为“cloudscrapper”的文件夹并将其粘贴到 your.exe 文件的同一路径中

The found solution is to copy the required folder inside the.exe path but as for now a days, I found that this could not be achieved if you're using the --onefile modifier to create the.exe , instead you should not use it and copy the cloudscraper folder inside such.exe path, and that should work找到的解决方案是将所需的文件夹复制到 .exe 路径中,但就目前而言,我发现如果您使用--onefile修饰符创建 .exe ,则无法实现,而不是您不应该使用它并在such.exe路径中复制cloudscraper文件夹,这应该可以

NOTE: The path is NOT THE PARENT FOLDER cloudscraper , instead is the nested folder which in it has the user_agent folder注意:路径不是父文件夹 cloudcraper ,而是嵌套文件夹,其中包含user_agent文件夹

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 pyinstaller 创建 exe 后没有名为“scipy”的模块 - No module named 'scipy' after creating exe with pyinstaller 使用Selenium模块创建一个Exe:Py2exe / Pyinstaller - Creating an Exe with Selenium Module: Py2exe/Pyinstaller 使用 pyinstaller 转换为 exe 时出现 Moviepy 模块错误 - Moviepy module error when converting to exe with pyinstaller 使用 Pyinstaller 创建 .exe 时出错 - Error while creating .exe using Pyinstaller 如何在通过 pyinstaller 创建 exe 文件时包含 timzonefinder 模块 - How to include timzonefinder module while creating an exe file via pyinstaller PyInstaller 未创建 .exe 文件 - PyInstaller is not creating an .exe file cloudscraper.exceptions.CloudflareChallengeError:检测到 Cloudflare 版本 2 挑战。 当我将 cloudscraper 模块与 python 一起使用时出错 - cloudscraper.exceptions.CloudflareChallengeError: Detected a Cloudflare version 2 challenge. Error when I used cloudscraper module with python exe 构建后的 Pyinstaller 错误:ModuleNotFoundError: No module named 'cmath' - Pyinstaller Error after exe built: ModuleNotFoundError: No module named 'cmath' 当 python ttp 模块就位时使用 pyinstaller exe 时出错 - error using pyinstaller exe when python ttp module is in place 使用pyinstaller创建.exe文件时出现Pytesseract错误 - Getting Pytesseract Error while creating .exe file using pyinstaller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM