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

Fix when frozen with cx_freeze #1030

Merged
merged 1 commit into from
Jan 14, 2020
Merged

Fix when frozen with cx_freeze #1030

merged 1 commit into from
Jan 14, 2020

Conversation

saddy001
Copy link
Contributor

@saddy001 saddy001 commented Jan 14, 2020

Fixes

    from weasyprint import HTML
  File "/usr/local/lib/python3.7/dist-packages/weasyprint/__init__.py", line 41, in <module>
    VERSION = __version__ = (ROOT / 'VERSION').read_text().strip()
TypeError: unsupported operand type(s) for /: 'str' and 'str'

Fixes

    from weasyprint import HTML
  File "/usr/local/lib/python3.7/dist-packages/weasyprint/__init__.py", line 41, in <module>
    VERSION = __version__ = (ROOT / 'VERSION').read_text().strip()
TypeError: unsupported operand type(s) for /: 'str' and 'str'
@saddy001
Copy link
Contributor Author

Oh well... I think there's more to it. The follow-up error is this one:

    from weasyprint import HTML
  File "/usr/local/lib/python3.7/dist-packages/weasyprint/__init__.py", line 41, in <module>
    VERSION = __version__ = (ROOT / 'VERSION').read_text().strip()
  File "/usr/lib/python3.7/pathlib.py", line 1206, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/usr/lib/python3.7/pathlib.py", line 1193, in open
    opener=self._opener)
  File "/usr/lib/python3.7/pathlib.py", line 1046, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/user/test/build/exe.linux-x86_64-3.7/VERSION'

So the final fix for me was this line:
ROOT = Path(os.path.join(os.path.dirname(sys.executable), 'lib', 'weasyprint'))

This might not be the general fix, but you may find it useful.

@saddy001
Copy link
Contributor Author

saddy001 commented Jan 14, 2020

The same line must be changed within /usr/local/lib/python3.7/dist-packages/cairosvg/__init__.py

@liZe
Copy link
Member

liZe commented Jan 14, 2020

Thank you!

(I’ve actually fixed this too in 647af0b 😉)

@liZe liZe merged commit f6494c9 into Kozea:master Jan 14, 2020
@liZe
Copy link
Member

liZe commented Jan 14, 2020

So the final fix for me was this line:
ROOT = Path(os.path.join(os.path.dirname(sys.executable), 'lib', 'weasyprint'))

I’ll check that

@saddy001 saddy001 deleted the patch-1 branch January 22, 2020 11:32
@grewn0uille grewn0uille added this to the 52 milestone Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants