I downloaded the source of lxml.

then unpacked it

typed "python setup.py install".

==> everything went fine.

but now typing :

import lxml

i get:

Traceback (most recent call last):

File "lxml.py", line 1, in

from lxml import etree

File "/Soft/fox_dev/dev/ut1u3h/dev/lxml.py", line 1, in

from lxml import etree

ImportError: cannot import name etree

Before you offer me any solution, I must tell you, our sys admins and network admins are control/Sercurity freaks.

I am not root

I cannot reach any url outside the company ( from the server on which i'm trying to install lxml on )

for example I tried to install pip:

>> python get-pip.py

Downloading/unpacking pip

Cannot fetch index base URL https://pypi.python.org/simple/

Could not find any downloads that satisfy the requirement pip

Cleaning up...

No distributions at all found for pip

Storing debug log for failure in /Home/ut1u3h/.pip/pip.log

I have a windows machine which can reach the web. Then I can transfer files from it to the linux server via sftp.

Any idea/solution ?

EDIT

first :

make inplace

python setup.py install

now if depending on the path on which I open the python interpreter, either it works or I get the above error. I've added the source too the pythonpath... but it does not chang anything !

EDIT2: solution

Please don't hurt me... the final solution: do not put a file named lxml.py in the directory from which you are trying to import lxml... rather name your test lxml_test.py !!!!

解决方案

probably you change the default python version python2.7 to other like python3.6, as we all known that some modules are different between the two versions, and some modules work bad with python3+, so you can reset your python version to 2.7

if you are using ubuntu, you can do as follows:

$ rm /usr/bin/python

$ ln -s /usr/bin/python2.7 /usr/bin/python

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐