I misread my own printout. The user site-packages directory is the one in
the middle:
C:\Users\tom\AppData\Roaming\Python\Python312\site-packages
On Thursday, September 12, 2024 at 11:51:24 PM UTC-4 Thomas Passin wrote:
> The dotted notation is used for relative imports, meaning relative to a
> path in *sys.path*. lxml is installed in my user *site-packages*
> directory - there it is at the bottom on my system:
>
> C:\Users\tom>py -c "import sys;print('\n'.join(sys.path))"
>
> C:\Users\tom\AppData\Local\Programs\Python\Python312\python312.zip
> C:\Users\tom\AppData\Local\Programs\Python\Python312\DLLs
> C:\Users\tom\AppData\Local\Programs\Python\Python312\Lib
> C:\Users\tom\AppData\Local\Programs\Python\Python312
> C:\Users\tom\AppData\Roaming\Python\Python312\site-packages
> C:\Users\tom\AppData\Roaming\Python
> C:\Users\tom\AppData\Roaming\Python\Python312\site-packages\win32
> C:\Users\tom\AppData\Roaming\Python\Python312\site-packages\win32\lib
> C:\Users\tom\AppData\Roaming\Python\Python312\site-packages\Pythonwin
> *C:\Users\tom\AppData\Local\Programs\Python\Python312\Lib\site-packages*
>
>
> lxml.html means find the *lxml* package and then the html subpackage
> *relative
> to it* (change paths for your system) starting at
>
> *C:\Users\tom\AppData\Local\Programs\Python\Python312\Lib\site-packages.*
>
> You can use dotted paths if your import subdirectories are set up right,
> which they are with lxml (change paths to suit your system) -
>
> import lxml.html
> PATH = r"C:\temp\freemind\basic_freemind.xml"
>
> htmltree = lxml.html.parse(PATH)
> print(htmltree)
>
> or this -
>
> import lxml.html as html
> PATH = r"C:\temp\freemind\basic_freemind.xml"
>
> htmltree = html.parse(PATH)
> print(htmltree)
>
> Read Sec 5.2 of the Python docs at
>
> https://docs.python.org/3/reference/import.html
>
> On Thursday, September 12, 2024 at 8:00:41 PM UTC-4 Félix wrote:
>
>> *(All this was tried with the Latest LXML version 5.3.0 )*
>>
>> I tried installing lxml with:
>>
>> pip install lxml
>>
>> Seems to have worked, but when importing a freemind file, the imported
>> lxml library does not have the 'html' member, and the import just errors
>> out.
>>
>> When exploring why the lxml library did not have any valid members, like
>> html or etree as per Leo uses it and was also in the official lxml docs, I
>> tried something :
>>
>> If I replace the import at the top of the leoImport.py file with :
>>
>>
>> *from lxml import html*instead of:
>> *import lxml*
>>
>> Then, replacing that line further down the file:
>>
>> *htmltree = lxml.html.parse(path)*
>> with this one:
>>
>> *htmltree = html.parse(path)*
>> ... makes everything works!! Wow! :)
>>
>> I'm a total newb with python so I'm wondering if someone can explain
>> this, and if they have the same behavior experience in Leo with importing
>> FreeMind (.mm or .mm.html files) in leo.
>>
>> Should I open an issue on github and suggest importing and using it this
>> way?
>>
>>
>>
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/leo-editor/c4ece1e2-edad-4524-9463-3e1bc96cf2b1n%40googlegroups.com.