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

Sigil fails to locate 'lxml module #249

Closed
cadencetech opened this issue Nov 8, 2016 · 14 comments
Closed

Sigil fails to locate 'lxml module #249

cadencetech opened this issue Nov 8, 2016 · 14 comments

Comments

@cadencetech
Copy link

cadencetech commented Nov 8, 2016

After installing python 3.5.4 on an updated Ubuntu 16.04 lts and installing all the addons specified in the Building_on_Linux.md and building and installing sigil from from source (git), I get the following errors. (Note: lxml is installed in both the native python 2.7.12 and python 3.5.4). I also tried building and executing in a virtual python3 environment and still get the following errors multiple times upon sigil launch:

Traceback (most recent call last):

File "C:/Program Files/Sigil/python3lib\xmlprocessor.py", line 6, in
from sigil_bs4.builder._lxml import LXMLTreeBuilderForXML

File "C:/Program Files/Sigil/plugin_launchers/python\sigil_bs4\builder_lxml.py", line 26, in
from lxml import etree

ImportError: No module named 'lxml'

Any help would be greatly appreciated.

@kevinhendricks
Copy link
Contributor

Python 2.7 usage has been removed from Sigil 0.9.7. Do you by chance have more than one python 3 version installed.

Please report the results of the following on the command line:

invoke python 3.5 from command line

python3

at the python3 prompt type the following

import lxml

Does it succeed?

KevinH

Sent from my iPad

On Nov 7, 2016, at 7:57 PM, cadencetech notifications@github.com wrote:

After installing python 3.5.4 on an updated Ubuntu 16.04 lts and installing all the addons specified in the Building_on_Linux.md and building and installing sigil from from source (git), I get the follwoing errors. (Note: lxml is installed in both the native python 2.7.12 and python 3.5.4). I also tried building and executing in a virtual python3 environment and still get the following errors multiple times upon sigil launch:

Traceback (most recent call last):

File "C:/Program Files/Sigil/python3lib\xmlprocessor.py", line 6, in
from sigil_bs4.builder._lxml import LXMLTreeBuilderForXML

File "C:/Program Files/Sigil/plugin_launchers/python\sigil_bs4\builder_lxml.py", line 26, in
from lxml import etree

ImportError: No module named 'lxml'

Any help would be greatly appreciated.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@kevinhendricks
Copy link
Contributor

Also are you trying to run it from the build tree or after installing?

KevinH

Sent from my iPad

On Nov 7, 2016, at 7:57 PM, cadencetech notifications@github.com wrote:

After installing python 3.5.4 on an updated Ubuntu 16.04 lts and installing all the addons specified in the Building_on_Linux.md and building and installing sigil from from source (git), I get the follwoing errors. (Note: lxml is installed in both the native python 2.7.12 and python 3.5.4). I also tried building and executing in a virtual python3 environment and still get the following errors multiple times upon sigil launch:

Traceback (most recent call last):

File "C:/Program Files/Sigil/python3lib\xmlprocessor.py", line 6, in
from sigil_bs4.builder._lxml import LXMLTreeBuilderForXML

File "C:/Program Files/Sigil/plugin_launchers/python\sigil_bs4\builder_lxml.py", line 26, in
from lxml import etree

ImportError: No module named 'lxml'

Any help would be greatly appreciated.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@cadencetech
Copy link
Author

I running it after installing it.

Best Regards,

Ed

Edward Hoffman

ehoffman333@gmail.com

From: Kevin Hendricks [mailto:notifications@github.com]
Sent: Monday, November 07, 2016 5:15 PM
To: Sigil-Ebook/Sigil
Cc: cadencetech; Author
Subject: Re: [Sigil-Ebook/Sigil] Sigil fails to locate 'lxml module (#249)

Also are you trying to run it from the build tree or after installing?

KevinH

Sent from my iPad

On Nov 7, 2016, at 7:57 PM, cadencetech notifications@github.com wrote:

After installing python 3.5.4 on an updated Ubuntu 16.04 lts and installing all the addons specified in the Building_on_Linux.md and building and installing sigil from from source (git), I get the follwoing errors. (Note: lxml is installed in both the native python 2.7.12 and python 3.5.4). I also tried building and executing in a virtual python3 environment and still get the following errors multiple times upon sigil launch:

Traceback (most recent call last):

File "C:/Program Files/Sigil/python3lib\xmlprocessor.py", line 6, in
from sigil_bs4.builder._lxml import LXMLTreeBuilderForXML

File "C:/Program Files/Sigil/plugin_launchers/python\sigil_bs4\builder_lxml.py", line 26, in
from lxml import etree

ImportError: No module named 'lxml'

Any help would be greatly appreciated.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #249 (comment) , or mute the thread https://github.com/notifications/unsubscribe-auth/AA3PkuD9EHqpZDf_Y4LZ1i3jJwkiaIk5ks5q780agaJpZM4Kr6QZ . https://github.com/notifications/beacon/AA3Pkv2UMKLZ06e9lmgB322fqk8qXtodks5q780agaJpZM4Kr6QZ.gif

@cadencetech
Copy link
Author

Thanks for your prompt answer! Ubuntu 16.04 lts installs both python2 and
python 3. Unfortunately it appears that they have not ported over the 2.7
code yet. Here are the results of the commands:

developer2@superquantan:~$ python3
Python 3.5.1 (default, Jun 12 2016, 20:40:17)
[GCC 4.6.4] on linux
Type "help", "copyright", "credits" or "license" for more information.

import lxml
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named 'lxml'

Apparently, python3 cannot find lxml. But lxml is installed:

developer2@superquantan:~$ cd /usr/lib/python3.5/dist-packages/lxml
developer2@superquantan:/usr/lib/python3.5/dist-packages/lxml$ ls -l
total 8560
-rw-r--r-- 1 root root 8152 Nov 7 15:58 builder.py
-rw-r--r-- 1 root root 3366 Nov 7 15:58 cssselect.py
-rw-r--r-- 1 root root 18387 Nov 7 15:58 doctestcompare.py
-rw-r--r-- 1 root root 7641 Nov 7 15:58 ElementInclude.py
-rw-r--r-- 1 root root 9490 Nov 7 15:58 _elementpath.py
-rwxr-xr-x 1 root root 5284056 Nov 7 15:58
etree.cpython-35m-x86_64-linux-gnu.so
drwxr-xr-x 3 root root 4096 Nov 7 15:58 html
drwxr-xr-x 6 root root 4096 Nov 7 15:58 includes
-rw-r--r-- 1 root root 551 Nov 7 15:58 init.py
drwxr-xr-x 4 root root 4096 Nov 7 15:58 isoschematron
-rw-r--r-- 1 root root 17450 Nov 7 15:58 lxml.etree_api.h
-rw-r--r-- 1 root root 8902 Nov 7 15:58 lxml.etree.h
-rwxr-xr-x 1 root root 3346736 Nov 7 15:58
objectify.cpython-35m-x86_64-linux-gnu.so
drwxr-xr-x 2 root root 4096 Nov 7 15:58 pycache
-rw-r--r-- 1 root root 92 Nov 7 15:58 pyclasslookup.py
-rw-r--r-- 1 root root 8531 Nov 7 15:58 sax.py
-rw-r--r-- 1 root root 230 Nov 7 15:58 usedoctest.py
developer2@superquantan:/usr/lib/python3.5/dist-packages/lxml$
any ideas?

On Mon, Nov 7, 2016 at 5:12 PM, Kevin Hendricks notifications@github.com
wrote:

Python 2.7 usage has been removed from Sigil 0.9.7. Do you by chance have
more than one python 3 version installed.

Please report the results of the following on the command line:

invoke python 3.5 from command line

python3

at the python3 prompt type the following

import lxml

Does it succeed?

KevinH

Sent from my iPad

On Nov 7, 2016, at 7:57 PM, cadencetech notifications@github.com
wrote:

After installing python 3.5.4 on an updated Ubuntu 16.04 lts and
installing all the addons specified in the Building_on_Linux.md and
building and installing sigil from from source (git), I get the follwoing
errors. (Note: lxml is installed in both the native python 2.7.12 and
python 3.5.4). I also tried building and executing in a virtual python3
environment and still get the following errors multiple times upon sigil
launch:

Traceback (most recent call last):

File "C:/Program Files/Sigil/python3lib\xmlprocessor.py", line 6, in

from sigil_bs4.builder._lxml import LXMLTreeBuilderForXML

File "C:/Program Files/Sigil/plugin_launchers/
python\sigil_bs4\builder_lxml.py", line 26, in
from lxml import etree

ImportError: No module named 'lxml'

Any help would be greatly appreciated.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#249 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA3Pkh3NBVe1n-i3SuKjoKi5rpAbIissks5q78x2gaJpZM4Kr6QZ
.

@dougmassay
Copy link
Contributor

dougmassay commented Nov 8, 2016

Did you install lxml with "pip3 install lxml" or with "apt-get install python3-lxml?"

With 16.04, I highly recommend using the Building_on_cutting_edge_Linux.md instructions instead of the older instructions. Everything necessary to build Sigil on 16.04 can be installed straight from the repositories with apt-get. I just did successful builds on 16.0.4 yesterday (Xenial and Kubuntu).

@cadencetech
Copy link
Author

both.

On Mon, Nov 7, 2016 at 6:18 PM, Doug Massay notifications@github.com
wrote:

Did you install lxml with "pip3 install lxml" or with "apt-get install
python3-lxml?"

With 16.04, I highly recommend using the Building_on_cutting_edge_Linux.md
instructions instead of the older instructions. Everything necessary to
build Sigil on 16.04 can be installed straight from the repositories with
apt-get. I just did a successful build on 16.0.4 yesterday.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#249 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA3PkuYFLE1isyce8vgiBylLSRNjODTLks5q79wPgaJpZM4Kr6QZ
.

@cadencetech
Copy link
Author

AS I mentioned in the original email, I used the instructions. I also had
installed many packages using apt-get before I used pip3 according to the
instructions. Is there some cleanup I need to do Should I remove all the
packages using apt-get remove?

On Mon, Nov 7, 2016 at 6:33 PM, Edward Hoffman ehoffman333@gmail.com
wrote:

both.

On Mon, Nov 7, 2016 at 6:18 PM, Doug Massay notifications@github.com
wrote:

Did you install lxml with "pip3 install lxml" or with "apt-get install
python3-lxml?"

With 16.04, I highly recommend using the Building_on_cutting_edge_Linux.md
instructions instead of the older instructions. Everything necessary to
build Sigil on 16.04 can be installed straight from the repositories with
apt-get. I just did a successful build on 16.0.4 yesterday.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#249 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA3PkuYFLE1isyce8vgiBylLSRNjODTLks5q79wPgaJpZM4Kr6QZ
.

@dougmassay
Copy link
Contributor

dougmassay commented Nov 8, 2016

both

Installed at the same time? Or did you first try one ... uninstall and then try the other? If both the pip version and package version are installed simultaneously, that could be the problem right there.

@dougmassay
Copy link
Contributor

AS I mentioned in the original email, I used the instructions. I also had
installed many packages using apt-get before I used pip3 according to the
instructions. Is there some cleanup I need to do Should I remove all the
packages using apt-get remove?

Actually, I'd remove the ones installed via "pip3 uninstall " and then verify they're all installed via apt-get instead. As I said, with a system as new as 16.04, you'll be better served following the newer instructions (Building_on_cutting_edge_Linux.md) instead of the other (Building_on Linux.md). Both documents are in the docs directory.

@kevinhendricks
Copy link
Contributor

This is not actually a Sigil bug at all but it would still help to figure out what causes it to prevent future reports.

@cadencetech
Copy link
Author

Kevin. I agree this is a python installation problem. I will work on it and provide a solution after which I'll provide documentation on the exact problem and the procedure to fix it.

Thanks for your help!

Best Regards,
Ed

Sent from my iPhone

On Nov 7, 2016, at 7:03 PM, Kevin Hendricks notifications@github.com wrote:

This is not actually a Sigil bug at all but it would still help to figure out what causes it to prevent future reports.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@cadencetech
Copy link
Author

Kevin,

This problem is a very simple problem with a simple solution.

Problem: Python can't locate installed packages.

The solution:

The short version is the sys.path in python3 does not contain the directory to the dist-packages . Add the missing path to PYTHONPATH in .bashrc.

The long version:

Step 1: Locate the python3 path as follows:

developer2@superquantan:~$ python3

Python 3.5.1 (default, Jun 12 2016, 20:40:17)

[GCC 4.6.4] on linux

Type "help", "copyright", "credits" or "license" for more information.

import sys

sys.path

['', '/usr/local/lib/python35.zip', '/usr/local/lib/python3.5', '/usr/local/lib/python3.5/plat-linux', '/usr/local/lib/python3.5/lib-dynload', '/home/developer2/.local/lib/python3.5/site-packages', '/usr/local/lib/python3.5/site-packages']

Checking the paths for site-packages all the site-package folders are empty.

Step 2: Locate the the installation path e.g. /usr/local/lib/python3.5/dist-packages and verify same by searching for lxml

developer2@superquantan:~$ cd /usr/local/lib/python3.5/dist-packages

developer2@superquantan:/usr/local/lib/python3.5/dist-packages$ ls -l|grep lxml

drwxr-sr-x 7 root staff 4096 Nov 7 00:17 lxml

drwxr-sr-x 2 root staff 4096 Nov 7 00:17 lxml-3.6.4.dist-info

developer2@superquantan:/usr/local/lib/python3.5/dist-packages$

Step 3. Edit the .bashrc file in your home directory to add the location of the dist-packages to the PYTHONPATH as follows:

export PYTHONPATH="/usr/local/lib/python3.5/dist-packages"

Step 4: Verify the new path as follows:

developer2@superquantan:~$ python3

Python 3.5.1 (default, Jun 12 2016, 20:40:17)

[GCC 4.6.4] on linux

Type "help", "copyright", "credits" or "license" for more information.

import sys

sys.path

['', '/usr/local/lib/python3.5/dist-packages', '/usr/local/lib/python35.zip', '/usr/local/lib/python3.5', '/usr/local/lib/python3.5/plat-linux', '/usr/local/lib/python3.5/lib-dynload', '/home/developer2/.local/lib/python3.5/site-packages', '/usr/local/lib/python3.5/site-packages']

Step 5; Launch Sigil

developer2@superquantan:~$ sigil

Sigil launches without any errors.

Kevin, Thanks for pointing me in the right direction.

Regards,

Ed

From: Edward Hoffman [mailto:ehoffman333@gmail.com]
Sent: Monday, November 07, 2016 7:36 PM
To: Sigil-Ebook/Sigil
Subject: Re: [Sigil-Ebook/Sigil] Sigil fails to locate 'lxml module (#249)

Kevin. I agree this is a python installation problem. I will work on it and provide a solution after which I'll provide documentation on the exact problem and the procedure to fix it.

Thanks for your help!

Best Regards,

Ed

Sent from my iPhone

On Nov 7, 2016, at 7:03 PM, Kevin Hendricks notifications@github.com wrote:

This is not actually a Sigil bug at all but it would still help to figure out what causes it to prevent future reports.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #249 (comment) , or mute the thread https://github.com/notifications/unsubscribe-auth/AA3PkmuZRXeAyVuozSEwwxUA1iXbHwneks5q7-Z-gaJpZM4Kr6QZ . https://github.com/notifications/beacon/AA3PkkaajfpuHEOxPvM7XcL7Afm45K2Cks5q7-Z-gaJpZM4Kr6QZ.gif

@mapreri
Copy link
Contributor

mapreri commented Nov 8, 2016

is that a python 3.5 you compiled yourself? Why not using the one from the Ubuntu archive? (that doesn't have that "problem"

>>> sys.path
['', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages']
>>> 

this is what I get from the thing in the archive.

@dougmassay
Copy link
Contributor

dougmassay commented Nov 8, 2016

I missed that about building Python 3.5.4 yourself. That would explain it. Even if you got lxml properly installed in your custom Python, it's very likely that Sigil's configuration grabbed the system Python for embedding/building (or vice versa).

You would have needed to add a few extra flags to the cmake command to tell it which specific python you wished to use. Those extra flags are documented in the Advanced section of the build instructions.

You should definitely use the custom-built pip3 to install modules in your custom Python. Apt-get will install modules into the system Python. As mapreri said, it would have been much easier just to use the Ubuntu-supplied Python. That's what both sets of Sigil build instructions are assuming is being done.

I'm going to close this issue a little later. Adding a custom-built Python to the mix is really beyond the scope of the standard build instructions for Linux.

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

No branches or pull requests

4 participants