WebFaction
Community site: login faq

I am attempting to set up a py3 wsgi site for testing, which uses lxml for some processing. Installing lxml generally uses easy_install...

Which is not installed for py3.1 or py3.2 (although I gave up on py3.2 when I discovered that WebFaction doesn't offer it in the application menu yet).

I really can't go back to py2.7 for this, and I would rather fall back to xml.etree.

Is there a plan to include easy_install-3.1 at some point? Or is there some other way to install lxml for py3.1?

asked 23 Sep '11, 09:52

seasong
113
accept rate: 0%


Regarding easy_install for Python 3.1, you might be able to get that working if you can manage to install distribute into your home directory with Python 3.1. However, I tried it with various incantations of --root and --prefix options, but distribute_setup.py always wanted to try to write to the system library directory, so the installation failed.

If you want to install lxml for Python 3.1 manually, you can install it with the following steps:

cd ~
mkdir -p bin lib/python3.1 src tmp
export TEMP=$HOME/tmp
export PYTHONPATH=$HOME/lib/python3.1
cd src
wget http://pypi.python.org/packages/source/l/lxml/lxml-2.3.tar.gz
tar zxf lxml-2.3.tar.gz
cd lxml-2.3
python3.1 setup.py build
python3.1 setup.py install --install-lib=$HOME/lib/python3.1 --install-scripts=$HOME/bin

You can use those same steps for Python 3.2 - just change the version wherever it appears. Hope that helps!

permanent link
This answer is marked "community wiki".

answered 23 Sep '11, 11:23

seanf
12.2k41836
accept rate: 37%

wikified 23 Sep '11, 19:51

I get this error in Python:

import lxml.etree

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

ImportError: lxml/etree.so: undefined symbol: libiconv

(23 Sep '11, 13:39) seasong

Can you please check your ~/lib/python3.1 directory and ensure that you don't have any old lxml libraries or eggs left over from a previous attempt at installation?

(23 Sep '11, 13:43) seanf

I deleted the bin, src, tmp, and lib/python3.1 directories and started over from scratch. I do have lxml installations in py2.x directories. Would that cause a problem?

(23 Sep '11, 14:18) seasong

No, that shouldn't cause a problem, unless you're adding your Python 2.x library directories to your Python 3 search path.

I just tried import lxml.etree on my test installation and got a similar error: ImportError: /home/seanf/lib/python3.1/lxml/etree.so: undefined symbol: gcry_check_version

I guess the static-deps flag didn't quite work as I thought it should. I'll try a different approach and will post back with my findings.

(23 Sep '11, 14:28) seanf

Ok, it seems the "--static-deps" flag was the problem. I've removed it from the steps in my answer.

I ran the same commands, but I removed the "--static-deps" flag from the "setup.py build" command, and then was able to import lxml.etree in a Python 3.1 session.

That's a first for me - usually static dependencies fix this sort of problem!

Anyway: delete lxml* from your ~/lib/python3.1 directory, then run the revised steps above, and you should be in business.

(23 Sep '11, 19:25) seanf

Worked perfectly with the revision. Thank you!

(24 Sep '11, 10:25) seasong

You're very welcome!

(24 Sep '11, 10:30) seanf
showing 5 of 7 show 2 more comments

Finally got Distribute working by copying from the Homebrew formula for it. Download the .tar.gz, extract it, cd into the resulting directory and run:

python3.2 setup.py install --install-scripts ~/bin --install-purelib ~/lib/python3.2/site-packages --install-platlib ~/lib/python3.2/site-packages

If you don't already have a python3.2 site-packages, run:

mkdir -p ~/lib/python3.2/site-packages

Keep in mind that you'll need to use the same -- options whenever you run setup.py install, or you will get the same write errors.

permanent link

answered 28 Oct '11, 10:45

kzurawel
1113
accept rate: 0%

For what it's worth, after getting the distribute-0.6.24 tarball, unpacking it, and cd-ing into the distribute-0.6.24 directory, I was able to install Distribute with the much simpler command:

PYTHONPATH=$HOME/lib/python3.2 python3.2 setup.py install --home=$HOME

as described in http://docs.webfaction.com/software/python.html#installing-packages-with-setup-py

From there a similar command allowed me to install packages under Python 3.2. In my case I was installing blogofile-0.8DEV from a git checkout, and it needs setuptools to install its dependencies.

(29 Dec '11, 21:17) dlatornell
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×337
×23
×16
×9
×1

question asked: 23 Sep '11, 09:52

question was seen: 7,223 times

last updated: 29 Dec '11, 21:17

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM