PreTeXtBook / pretext-cli

Command line interface for quickly creating, authoring, and building PreTeXt documents.
https://pretextbook.org
GNU General Public License v3.0
17 stars 18 forks source link

Python3.9/Catalina problem? #70

Closed seanteachesmath closed 3 years ago

seanteachesmath commented 3 years ago

I can't troubleshoot this to know if it is a pretext problem, python, or something else.

Until recently things had been working perfectly, perhaps this has something to do with a recent Catalina update (10.15.7). Here's some output when I try pretext build html on a pretext-generated "test" project.

Traceback (most recent call last): File "/Users/myname/Library/Python/3.9/bin/pretext", line 8, in sys.exit(main()) File "/Users/myname/Library/Python/3.9/lib/python/site-packages/click/core.py", line 829, in call return self.main(args, kwargs) File "/Users/myname/Library/Python/3.9/lib/python/site-packages/click/core.py", line 782, in main rv = self.invoke(ctx) File "/Users/myname/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/myname/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1066, in invoke return ctx.invoke(self.callback, ctx.params) File "/Users/myname/Library/Python/3.9/lib/python/site-packages/click/core.py", line 610, in invoke return callback(args, **kwargs) File "/Users/myname/Library/Python/3.9/lib/python/site-packages/pretext/cli.py", line 147, in build build.html(source,html_output,stringparams) File "/Users/myname/Library/Python/3.9/lib/python/site-packages/pretext/build.py", line 10, in html xslfile = os.path.join(static.filepath('xsl'), 'pretext-html.xsl') File "/Users/myname/Library/Python/3.9/lib/python/site-packages/pretext/static/__init__.py", line 11, in filepath with pkg_resources.path(__name__, filename) as p: File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 117, in __enter__ return next(self.gen)

File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/resources.py", line 175, in _path_from_reader opener_reader = reader.open_resource(norm_resource)

File "", line 995, in open_resource IsADirectoryError: [Errno 21] Is a directory: '/Users/myname/Library/Python/3.9/lib/python/site-packages/pretext/static/xsl'`

rbeezer commented 3 years ago

I don't see anything that makes me think it is PreTeXt stylesheets causing this.

StevenClontz commented 3 years ago

I don't have a Python 3.9 installation handy to check this for myself. Can you reproduce this error and provide all the steps you went through, starting with (it seems) pretext new?

seanteachesmath commented 3 years ago

Thanks to you both. I'm not sure what changed in the past few weeks. I might have fooled around with Python a bit much a few weeks ago while trying to learn manim.

Here's what it looks like (though this doesn't add much more than what was above). What's interesting is that I can make a new project, I can see the help menu, versions, but build seems to fail: myname@Seans-MBP ~ % pretext new "Test" Generating new PreTeXt project in test. myname@Seans-MBP ~ % cd test myname@Seans-MBP test % pretext build html Traceback (most recent call last): File "/Users/myname/Library/Python/3.9/bin/pretext", line 8, in sys.exit(main()) File "/Users/myname/Library/Python/3.9/lib/python/site-packages/click/core.py", line 829, in call return self.main(args, kwargs) File "/Users/myname/Library/Python/3.9/lib/python/site-packages/click/core.py", line 782, in main rv = self.invoke(ctx) File "/Users/myname/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/myname/Library/Python/3.9/lib/python/site-packages/click/core.py", line 1066, in invoke return ctx.invoke(self.callback, ctx.params) File "/Users/myname/Library/Python/3.9/lib/python/site-packages/click/core.py", line 610, in invoke return callback(args, **kwargs) File "/Users/myname/Library/Python/3.9/lib/python/site-packages/pretext/cli.py", line 147, in build build.html(source,html_output,stringparams) File "/Users/myname/Library/Python/3.9/lib/python/site-packages/pretext/build.py", line 10, in html xslfile = os.path.join(static.filepath('xsl'), 'pretext-html.xsl') File "/Users/myname/Library/Python/3.9/lib/python/site-packages/pretext/static/init.py", line 11, in filepath with pkg_resources.path(name, filename) as p: File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 117, in enter return next(self.gen) File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/resources.py", line 175, in _path_from_reader opener_reader = reader.open_resource(norm_resource) File "", line 995, in open_resource IsADirectoryError: [Errno 21] Is a directory: '/Users/myname/Library/Python/3.9/lib/python/site-packages/pretext/static/xsl' myname@Seans-MBP test %

StevenClontz commented 3 years ago

Yeah, this was the push I needed to get https://github.com/pyenv/pyenv running on my machine. I can confirm I also get this error on a fresh Python 3.9 install.

I'm guessing it's that the hacky way we're distributing rbeezer/mathbook resources has been broken in 3.9. So we could try to bugfix this, but I think the better use of our time is to accelerate talks on distributing those core resources via PyPI as a package directly. @rbeezer @oscarlevin I can join the virtual pretext meeting this afternoon if y'all will have time to discuss.

For the immediate future, I'm afraid the only fix I have is to not use pretext-cli with 3.9.

oscarlevin commented 3 years ago

I plan to drop by development time, but not until 2:30 or 3 (MST).

rbeezer commented 3 years ago

I'll be there, of course. @Alex-Jordan needs a dedicated 30 minutes (not sure just when) so that'll take priority.

seanteachesmath commented 3 years ago

Thanks everyone, taking a somewhat extreme approach (sensing there might be all sorts of little things going wrong), I wiped and reinstalled my OS (Big Sur). Happy to report that things are working now, though somewhere along the way there were some issues getting "Pillow" installed.

StevenClontz commented 3 years ago

When you say the CLI is working, are you still using Python 3.9? That'd be surprising to me, since I got the same error on a fresh 3.9 install myself.

seanteachesmath commented 3 years ago

It is working, error free, with a fresh 3.9. At the moment I'm on Big Sur with Python 3.9.0. Sorry to have stirred this conversation up, and worked around the problem without much ability to help out in the end.

StevenClontz commented 3 years ago

Well, here's what I'm getting (using pyenv anyway):

$ python -V
Python 3.9.0
$ pretext --version
0.1.2
$ pretext new my-book
Generating new PreTeXt project in `my-book`.
$ cd my-book/
$ pretext build
Traceback (most recent call last):
  File "/home/user/.pyenv/versions/3.9.0/bin/pretext", line 8, in <module>
    sys.exit(main())
  File "/home/user/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/home/user/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/user/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/user/.pyenv/versions/3.9.0/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/user/.pyenv/versions/3.9.0/lib/python3.9/site-packages/pretext/cli.py", line 147, in build
    build.html(source,html_output,stringparams)
  File "/home/user/.pyenv/versions/3.9.0/lib/python3.9/site-packages/pretext/build.py", line 10, in html
    xslfile = os.path.join(static.filepath('xsl'), 'pretext-html.xsl')
  File "/home/user/.pyenv/versions/3.9.0/lib/python3.9/site-packages/pretext/static/__init__.py", line 11, in filepath
    with pkg_resources.path(__name__, filename) as p:
  File "/home/user/.pyenv/versions/3.9.0/lib/python3.9/contextlib.py", line 117, in __enter__
    return next(self.gen)
  File "/home/user/.pyenv/versions/3.9.0/lib/python3.9/importlib/resources.py", line 175, in _path_from_reader
    opener_reader = reader.open_resource(norm_resource)
  File "<frozen importlib._bootstrap_external>", line 995, in open_resource
IsADirectoryError: [Errno 21] Is a directory: '/home/user/.pyenv/versions/3.9.0/lib/python3.9/site-packages/pretext/static/xsl'
seanteachesmath commented 3 years ago

That is very reflective of what I encountered, if that provides any support.

StevenClontz commented 3 years ago

Talking with @oscarlevin we're not sure what's breaking, but we think that https://github.com/PreTeXtBook/pretext-cli/blob/master/pretext/static/__init__.py#L7 is brittle in any case, so we're going to refactor it to not take a filename (and use os.path.join instead)

StevenClontz commented 3 years ago

We didn't get to chat with you @rbeezer but we're now skeptical that rbeezer/mathbook#1384 would help us solve this problem anyway, so we can delay that chat for a while.

rbeezer commented 3 years ago

Right. Oscar caught me up near the end. Sorry to have missed you, there was a lot of discussion today....

oscarlevin commented 3 years ago

@StevenClontz, I don't remember where we left this. Did we push a patch that "fixes" the problem? I ask because today I was helping a colleague get up and running with PreTeXt for the first time and he was getting a permission denied error using Python 3.9 and pretextbook 0.1.2. Here is his traceback:

PS C:\Users\tmarkkanen\srp-book> pretext build html
Traceback (most recent call last):
  File "c:\users\tmarkkanen\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\tmarkkanen\appdata\local\programs\python\python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\tmarkkanen\AppData\Local\Programs\Python\Python39\Scripts\pretext.exe\__main__.py", line 7, in <module>
  File "c:\users\tmarkkanen\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\tmarkkanen\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "c:\users\tmarkkanen\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\tmarkkanen\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\tmarkkanen\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "c:\users\tmarkkanen\appdata\local\programs\python\python39\lib\site-packages\pretext\cli.py", line 147, in build
    build.html(source,html_output,stringparams)
  File "c:\users\tmarkkanen\appdata\local\programs\python\python39\lib\site-packages\pretext\build.py", line 10, in html
    xslfile = os.path.join(static.filepath('xsl'), 'pretext-html.xsl')
  File "c:\users\tmarkkanen\appdata\local\programs\python\python39\lib\site-packages\pretext\static\__init__.py", line 11, in filepath
    with pkg_resources.path(__name__, filename) as p:
  File "c:\users\tmarkkanen\appdata\local\programs\python\python39\lib\contextlib.py", line 117, in __enter__
    return next(self.gen)
  File "c:\users\tmarkkanen\appdata\local\programs\python\python39\lib\importlib\resources.py", line 175, in _path_from_reader
    opener_reader = reader.open_resource(norm_resource)
  File "<frozen importlib._bootstrap_external>", line 995, in open_resource
PermissionError: [Errno 13] Permission denied: 'c:\\users\\tmarkkanen\\appdata\\local\\programs\\python\\python39\\lib\\site-packages\\pretext\\static\\xsl' 

Same issue or different?

oscarlevin commented 3 years ago

This should be fixed in 0.1.3. Issue seems to be with the importlib library on python 3.9 not accepting a directory as its argument. This is a temporary fix until we decide how to better handle the xsl static resources.