python lxml异入不了etree_lxml无法导入元素etree

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值