Al Lelopath Al Lelopath - 13 days ago 5
Python Question

How to refer a project to install package in PyDev

I downloaded

lxml-3.4.4-cp27-none-win_amd64.whl
from
http://www.lfd.uci.edu/~gohlke/pythonlibs/, then put it in
D:\My Documents\lxml
. After that I opened the Windows CMD and changed directory to
D:\My Documents\lxml
and then did:

>>pip install --index-url http://www.lfd.uci.edu/~gohlke/pythonlibs/ lxml-3.4.4-cp27-none-win_amd64.whl
unpacking d:\my documents\lxml\lxml-3.4.4-cp27-none-win_amd64.whl
Installing collected packages: lxml
Successfully installed lxml
Cleaning up...


How do I now refer to this in an Eclipse/PyDev project?

Edit: (getting closer)

From https://pypi.python.org/pypi/lxml/3.5.0 download
lxml-3.5.0.win-amd64-py2.7.exe
(md5)

Run this exe, installing to Python Directory:
C:\Python27\


Eclipse/PyDev project Python27LibSitePackages now contains
lxml
package and
lxml-3.5.0.py2.7.egg-info


Create PyDev project from
C:\Python27\Lib\site-packages
as suggested by @caot below. This project now contains
lxml
package and
lxml-3.5.0.py2.7.egg-info
.

In the project that I want to use
lxml
, I go to Properties > Project References and include the SitePackages project by checking the box.

Still get the error NameError: global name 'etree' is not defined

Go to Project Properties > External Libraries > Add source folder
C:\Python27\Lib\site-packages\lxml


Still get the error NameError: global name 'etree' is not defined

Edit 2:

Under
C:\Python27\site-packages
, I do not see
etree.dll
. There is:

etree.pyd
lxml.etree_api.h
lxml.etree.h
dtree_defs.h
etreepublic.pxd


Edit 3:
The answer seems to be:


  • Download .exe (as stated by @caot)

  • Be sure that only
    C:\Python27\Lib\site-packages
    should be in
    PYTHONPATH
    , as @Zabio Zadrozny pointed out (via Properites > PyDev-PYTHONPATH > External Libraries > Add source folder)

  • Restart Eclipse (as @caot said) a few times until it takes.


Answer

Linux: download lxml-3.5.0.tar.gz, and run: python setup.py install

Windows: install lxml-3.5.0.win-amd64-py2.7.exe

$ python
Python 2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml
>>> from lxml import etree
>>> etree.LXML_VERSION
(3, 5, 0, 0)
>>>
Comments