Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I cannot import a python package that I can happily import using the same path within a python file run in IDLE.

I am new to SageMath and to PreTeXt that I am using it with. I cannot import a python package that I can happily import using the same path within a python file run in IDLE. If I remove the "import sys ... import ternary" lines the PreTeXt code runs fine and I get the sin curve. The ternary module is Marc Harper's installed from GitHub using pip. But the module is not found when I run with the 3 lines added (so I have not bothered to add code that uses the module yet!). (To keep code to a minimum in the <interactive> ... </interactive> part I would ideally like to be able to import python code). Can anyone put me on the right track please? (PSWith a Karma of 1 I had to remove the links at the top of the code indoor to have the question accepted)

<book xml:id="prog1" xml:lang="en-US"> <title>prog1</title> <chapter xml:id="my-chapter"> <interactive xml:id="simple-plot" platform="sage" width="100%" aspect="1:1"> <slate surface="sage"> plot(sin,(-5,5)) import sys sys.path.append("/usr/local/lib/python3.8/site-packages/") import ternary </slate> </interactive> </chapter> </book> </pretext>