'pretext' is not a package

74 views
Skip to first unread message

ksk...@gmail.com

unread,
Jun 30, 2022, 8:02:07 PM6/30/22
to PreTeXt support
Okay, this is strange. One moment the PreTeXt CLI is working fine, and the next it starts failing thusly:

Traceback (most recent call last):
  File "/usr/local/bin/pretext", line 5, in <module>
    from pretext.cli import main
ModuleNotFoundError: No module named 'pretext.cli'; 'pretext' is not a package

This is on current Ubuntu (22.04). Thoughts?

Kiran

Mitch Keller

unread,
Jul 1, 2022, 1:25:18 PM7/1/22
to pretext...@googlegroups.com
Have you tried

python -m pretext

to see if it can be found that way? In the early 0.7 series, we had some issues on macOS with pretext not being found. (Also, make sure you’ve updated…if you’re on an early 0.7.x, that might be biting you the way it bit me.)
> --
> You received this message because you are subscribed to the Google Groups "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pretext-support/7e1b2652-bee6-4fc3-9c6b-dcf0a0ad224fn%40googlegroups.com.

--
Mitch Keller
mi...@rellek.net

http://www.rellek.net/

ksk...@gmail.com

unread,
Jul 2, 2022, 11:24:29 AM7/2/22
to PreTeXt support
"python -m pretext" returns with no error message. Similarly, running Python (3.10.4) and executing "from pretext import *" returns with no error message.

For the record, this is pretextbook-0.8.1, but downgrading (e.g., pip install pretextbook=0.7.0) doesn't seem to make much difference.

ksk...@gmail.com

unread,
Jul 4, 2022, 6:24:21 PM7/4/22
to PreTeXt support
Also for the record, I can run the CLI inside a "sage -sh" session with no problem. Strange, because I'm pretty sure Sage is using the system Python, so I'm not sure why there should be a discrepancy.

Kiran

ksk...@gmail.com

unread,
Jul 15, 2022, 12:34:11 AM7/15/22
to PreTeXt support
In case this is a further clue: "python -m pretext.cli" returns this error message:

/usr/bin/python: Error while finding module specification for 'pretext.cli' (ModuleNotFoundError: __path__ attribute not found on 'pretext' while trying to find 'pretext.cli')

Oscar Levin

unread,
Jul 15, 2022, 9:15:00 PM7/15/22
to PreTeXt support
I'm not sure what you are trying to do here, and why you would type `pretext.cli` anywhere.  What happens when you enter `pretext --version` and `python -m pretext --version`?

What happens when you uninstall and reinstall: `pip uninstall pretextbook` and then `pip install pretextbook`?

ksk...@gmail.com

unread,
Jul 16, 2022, 1:07:17 PM7/16/22
to PreTeXt support
Quick recap of the problem:

"pretext ..." with any arguments returns:
Traceback (most recent call last):
  File "/usr/local/bin/pretext", line 5, in <module>
    from pretext.cli import main
ModuleNotFoundError: No module named 'pretext.cli'; 'pretext' is not a package

while "python -m pretext --version" returns nothing (no error but also no output). "pip uninstall pretextbook" followed by "pip install pretextbook" seems to have no effect on this behavior.

By contrast, inside a "sage -sh" sesson, "pretext --version" and "python -m pretext --version" both return "0.8.1", and the CLI basically behaves normally. That maybe suggests a problem with one of my environment variables?

Kiran

Rob Beezer

unread,
Jul 16, 2022, 1:19:25 PM7/16/22
to pretext...@googlegroups.com
I'm sure the CLI guys will have better ideas, but have you tried this in a
Python virtual environment, which should be somewhat isolated (and you can trash
it once done testing).

https://pretextbook.org/doc/guide/html/python-virtual.html
> <https://groups.google.com/d/msgid/pretext-support/7e1b2652-bee6-4fc3-9c6b-dcf0a0ad224fn%40googlegroups.com>.
>
>
> --
> Mitch Keller
> mi...@rellek.net
>
> http://www.rellek.net/ <http://www.rellek.net/>
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-suppo...@googlegroups.com
> <mailto:pretext-suppo...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pretext-support/9189239a-40a4-443b-b528-2c394e1bb61an%40googlegroups.com
> <https://groups.google.com/d/msgid/pretext-support/9189239a-40a4-443b-b528-2c394e1bb61an%40googlegroups.com?utm_medium=email&utm_source=footer>.

Oscar Levin

unread,
Jul 16, 2022, 7:54:24 PM7/16/22
to PreTeXt support
This really does seem like something caused by weird python install stuff (I know I have accidentally had two versions of python installed and have no idea when each was actually being used for things).  Some things you might try and share here:

What do you get from `python --version` and `which python`?
What about `pip --version`?
What's the output of `pip list`? 
Inside the sage -sh, what is the output of `pretext support`?

Oh, I assume you have set up `python` to be `python3` right?  I don't remember what ubuntu does with that now.

You might also try manually deleting the /usr/local/bin/pretext directory and then reinstalling via pip.

The virtual environment will likely also help.

ksk...@gmail.com

unread,
Jul 17, 2022, 2:05:52 PM7/17/22
to PreTeXt support
Let's see...

Working inside a virtual environment seems to make no difference (?!).

Python version is 3.10.4, located at /usr/bin/python which is actually a simlink to /usr/bin/python3.

"pip list" is a long messy list, so I haven't included it here. Am I looking for anything in particular?

Inside the sage -sh, "pretext support" returns:

PreTeXt-CLI version: 0.8.1
PyPI link: https://pypi.org/project/pretextbook/0.8.1/
PreTeXt core resources commit: cdd5a5333a3332a48cae1e3289c4461520c7476e
OS: Linux-5.15.0-40-generic-x86_64-with-glibc2.35
Python version: 3.10.4

Kiran

Oscar Levin

unread,
Jul 17, 2022, 4:25:07 PM7/17/22
to PreTeXt support
Even stranger.  Is there any chance you have two pythons or two pretexs installed?  If you do pip list, do you see pretextbook?  Any chance you also see pretext?  There is another python package named pretext that maybe got installed by accident, although I don't know why that would cause an issue.  

Do you get anything different if you use `python -m pip install pretextbook` from just `pip install pretextbook`?  

At this point your best bet might be to completely uninstall python and start over.  In particular, delete /usr/bin/python and /usr/bin/pretext, and any other versions of python you have installed.  

ksk...@gmail.com

unread,
Jul 18, 2022, 10:32:23 AM7/18/22
to PreTeXt support
I tried "pip uninstall pretext" and that worked! Might be worth adding a warning somewhere that having this package present could cause problems.

As for why this wasn't broken inside sage -sh, "pip list" gives totally different results there, so even though it's the same systemwide Python (I checked) the two instances of pip are presumably using different local folders to store the downloaded packages.

Anyway, thanks for the suggestions! Let's just hope I didn't actually need the other pip package for anything...
Reply all
Reply to author
Forward
0 new messages