最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - ValueError: source code string cannot contain null bytes when launching py2app application - Stack Overflow

programmeradmin2浏览0评论

I have written a python code and am converting it into an app using py2app however I'm getting a launch error that mentions an issue with the pandas library (As i mentioned in the title)

I'm using python 3.11.0, UTF-8 in vscode.

I reinstalled pandas library and rebuilt the app - but kept getting the same error Then i tried switching to python 3.13.2 but i got even more errors.

from setuptools import setup  

APP = ['main.py']  
OPTIONS = {
    'argv_emulation': False,
    'packages': ['pandas', 'openpyxl', 'ctypes','cmath'],  # Ensure package is included
    'includes': ['tkinter', 'file_handler', 'excel_manager2', 'citation_parser', 'utils', 'config'],
    'excludes': []
}

setup(
    app=APP,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)

This code is run with py2app
python3 "filename.py" py2app

Then I have also codesigned it

This creates two folders 'build' and 'dist' in the source directory. The 'dist' directory contains an app that will run 'main.py' which is also stored in the same directory.

However, when I run the app in terminal I am getting this error:

Traceback (most recent call last):
  File "/Users/aarush/Desktop/Research Internship/Literature Organisation Code/Code Package/dist/main.app/Contents/Resources/__boot__.py", line 170, in <module>
    _run()
  File "/Users/aarush/Desktop/Research Internship/Literature Organisation Code/Code Package/dist/main.app/Contents/Resources/__boot__.py", line 84, in _run
    exec(compile(source, path, "exec"), globals(), globals())
  File "/Users/aarush/Desktop/Research Internship/Literature Organisation Code/Code Package/dist/main.app/Contents/Resources/main.py", line 7, in <module>
    from excel_manager2 import load_or_create_excel, append_data_to_excel
  File "excel_manager2.pyc", line 2, in <module>
  File "/Users/aarush/Desktop/Research Internship/Literature Organisation Code/Code Package/dist/main.app/Contents/Resources/lib/python3.11/pandas/__init__.py", line 139, in <module>
    from pandas import testing
  File "/Users/aarush/Desktop/Research Internship/Literature Organisation Code/Code Package/dist/main.app/Contents/Resources/lib/python3.11/pandas/testing.py", line 6, in <module>
    from pandas._testing import (
  File "/Users/aarush/Desktop/Research Internship/Literature Organisation Code/Code Package/dist/main.app/Contents/Resources/lib/python3.11/pandas/_testing/__init__.py", line 46, in <module>
    from pandas._testing.asserters import (
  File "/Users/aarush/Desktop/Research Internship/Literature Organisation Code/Code Package/dist/main.app/Contents/Resources/lib/python3.11/pandas/_testing/asserters.py", line 16, in <module>
    import pandas._libs.testing as _testing
  File "testing.pyx", line 1, in init pandas._libs.testing
ValueError: source code string cannot contain null bytes
2025-03-16 11:04:24.844 main[41437:1508843] Launch error
2025-03-16 11:04:24.844 main[41437:1508843] Launch error
See the py2app website for debugging launch issues
2025-03-16 11:04:25.234 main[41437:1508843] +[IMKClient subclass]: chose IMKClient_Modern
2025-03-16 11:04:25.234 main[41437:1508843] +[IMKInputSession subclass]: chose IMKInputSession_Modern

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论