Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: source code string cannot contain null bytes #416

Open
f1am3d opened this issue Dec 3, 2023 · 3 comments
Open

ValueError: source code string cannot contain null bytes #416

f1am3d opened this issue Dec 3, 2023 · 3 comments

Comments

@f1am3d
Copy link

f1am3d commented Dec 3, 2023

Another repo, another error...

After running api/setup-amd.bat:

"Downloading and converting models to ONNX format..."
Traceback (most recent call last):
File "C:\Users\f1am3d\miniconda3\envs\Automatic1111_olive\lib\runpy.py", line 187, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, Error)
File "C:\Users\f1am3d\miniconda3\envs\Automatic1111_olive\lib\runpy.py", line 110, in get_module_details
import(pkg_name)
File "C:\Users\f1am3d\repos\onnx-web\api\onnx_web_init
.py", line 2, in
from .chain import (
File "C:\Users\f1am3d\repos\onnx-web\api\onnx_web\chain_init
.py", line 1, in
from .pipeline import ChainPipeline, PipelineStage, StageParams
File "C:\Users\f1am3d\repos\onnx-web\api\onnx_web\chain\pipeline.py", line 9, in
from ..output import save_image
File "C:\Users\f1am3d\repos\onnx-web\api\onnx_web\output.py", line 13, in
from onnx_web.convert.utils import resolve_tensor
File "C:\Users\f1am3d\repos\onnx-web\api\onnx_web\convert\utils.py", line 8, in
import requests
ValueError: source code string cannot contain null bytes

@ssube
Copy link
Owner

ssube commented Dec 3, 2023

Hi, it looks like you might have a broken installation of the requests package. That is not a package that I maintain, but it is necessary to run the conversion tools (for downloading models for civitai, etc).

To verify that the requests package is the problem, you can run the following in a command prompt, from your onnx_web folder:

cd api
onnx_env\Scripts\Activate.bat
python

Once the python shell starts up, try to import requests. If that prints the same error, the package is the problem. If not, please let me know.

If the error is the same, you can run pip install --force-reinstall requests in the same command prompt, and that should replace any broken files from before.

@f1am3d
Copy link
Author

f1am3d commented Dec 3, 2023

Once the python shell starts up, try to import requests. If that prints the same error, the package is the problem. If not, please let me know.

Yes, it prints the same error.

If the error is the same, you can run pip install --force-reinstall requests in the same command prompt, and that should replace any broken files from before.

Didn't help. I installed everything from scratch again - result is the same.

Traceback (most recent call last):
  File "C:\Users\f1am3d\repos\onnx-web\api\scripts\test-diffusers.py", line 1, in <module>
    from diffusers import OnnxStableDiffusionPipeline
  File "C:\Users\f1am3d\repos\onnx-web\api\onnx_env\lib\site-packages\diffusers\__init__.py", line 3, in <module>
    from .configuration_utils import ConfigMixin
  File "C:\Users\f1am3d\repos\onnx-web\api\onnx_env\lib\site-packages\diffusers\configuration_utils.py", line 29, in <module>
    from huggingface_hub import create_repo, hf_hub_download
  File "<frozen importlib._bootstrap>", line 1075, in _handle_fromlist
  File "C:\Users\f1am3d\repos\onnx-web\api\onnx_env\lib\site-packages\huggingface_hub\__init__.py", line 322, in __getattr__
    submod = importlib.import_module(submod_path)
  File "C:\Users\f1am3d\miniconda3\envs\Automatic1111_olive\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\f1am3d\repos\onnx-web\api\onnx_env\lib\site-packages\huggingface_hub\hf_api.py", line 35, in <module>
    from huggingface_hub.utils import (
  File "C:\Users\f1am3d\repos\onnx-web\api\onnx_env\lib\site-packages\huggingface_hub\utils\__init__.py", line 44, in <module>
    from ._headers import build_hf_headers, get_token_to_send, LocalTokenNotFoundError
  File "C:\Users\f1am3d\repos\onnx-web\api\onnx_env\lib\site-packages\huggingface_hub\utils\_headers.py", line 20, in <module>
    from ._runtime import (
  File "C:\Users\f1am3d\repos\onnx-web\api\onnx_env\lib\site-packages\huggingface_hub\utils\_runtime.py", line 20, in <module>
    import packaging.version
ValueError: source code string cannot contain null bytes

@ssube
Copy link
Owner

ssube commented Dec 26, 2023

The second error looks like it's from a different package:

  File "C:\Users\f1am3d\repos\onnx-web\api\onnx_env\lib\site-packages\huggingface_hub\utils\_runtime.py", line 20, in <module>
    import packaging.version

with packaging.version instead of requests. It sounds like you might have some broken packages installed from something else.

You could reinstall each of them, however, I recently released the Windows bundle for v0.11 which wraps Python and all of the necessary libraries into a single EXE file, which might make things easier: https://github.com/ssube/onnx-web/releases/tag/v0.11.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants