Do I need 32bit libxml2 for python on a snow leopard?

I have a hell of a scrapy installation time on my sl mbp. it requires libxml2, so I decided to install this. installing it from macports does not seem to reset the python binding.

installing it from the source using scrapy instructions ( here ) sets the python bindings, but when I run python -c, import libxml2 "I get an architecture mismatch:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "libxml2.py", line 1, in <module>
    import libxml2mod
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-    packages/libxml2mod.so, 2): no suitable image found.  Did find:
    /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-    packages/libxml2mod.so: mach-o, but wrong architecture

when I explicitly create the libxml2 dll as 32-bit, this error goes away, but then libxslt will not build due to the fact that some other library will not be 32-bit. I'm afraid to keep pulling this line. so the question is only python 32bit? am i doing something stupid here?

edit is python 2.6

edit 2 - by popular request, I am consolidating @Ned Deily amazing answer here. all to him on credit, I just publish the steps that I took based on his answer:

if you trick mac ports (and didn't install anything else through them that you need), nuke them.

$ sudo rm -r /opt/local

add the following to /opt/local/etc/macports/variants.confto prevent the entire unix library from loading with the following commands

+bash_completion +quartz +ssl +no_x11 +no_neon +no_tkinter +universal +libyaml -scientific

install macports python version

$ sudo port install python26

set prerequisites for <

sudo port install py26-libxml2 py26-twisted py26-openssl py26-simplejson py26-setuptools python_select
sudo python_select python26

check that the correct python is selected: run it $ which python, which should say something in the lines '/ opt / local / bin / python', and that at its discretion there should be a link to / opt / local / bin / python 2.6.

, : file 'which python' ( , ( Intel, 10.6):

/opt/local/bin/python2.6: Mach-O universal binary with 2 architectures
/opt/local/bin/python2.6 (for architecture x86_64): Mach-O 64-bit executable x86_64
/opt/local/bin/python2.6 (for architecture i386):   Mach-O executable i386

, libxml

$ python -c 'import libxml2'

, .

scrapy

sudo /opt/local/bin/easy_install-2.6 scrapy

( ), , . , .

+3
4

, , python.org python 2.6.4 ( /Library/Frameworks/Python.frameworks...). 32-. 10.6 MacPorts 64- . MacPorts, +universal MacPorts /opt/local/etc/macports/variants.conf. , , , , , 64- python2.6 MacPorts. , . $PATH, /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin /opt/local/bin Python . - (!):

sudo port selfupdate  # ensure you have the latest ports file information
sudo port install py26-libxml2 py26-twisted py26-openssl py26-simplejson py26-setuptools python_select
sudo python_select python26  # optionally make /opt/local/bin/python -> python2.6
sudo /opt/local/bin/easy_install-2.6 scrapy
# or install manually
cd /path/to/scrapy
sudo /opt/local/bin/python2.6 setup.py install

EDIT: 10.6 - Tk 64- Tk X11, , , . /opt/local/etc/macports/variants.conf 10.6 ( python ):

+bash_completion +quartz +ssl +no_x11 +no_neon +no_tkinter +universal +libyaml -scientific

EDIT: MacPorts , - 10.6:

$ ls -l /opt/local/bin/python2.6
lrwxr-xr-x  1 root  wheel  73 Oct 28 20:25 /opt/local/bin/python2.6@ -> /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
$ file /opt/local/bin/python2.6
/opt/local/bin/python2.6: Mach-O universal binary with 2 architectures
/opt/local/bin/python2.6 (for architecture x86_64): Mach-O 64-bit executable x86_64
/opt/local/bin/python2.6 (for architecture i386):   Mach-O executable i386

, +universal, x86_64 i386.

, $PATH MacPorts:

$ echo $PATH
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin:/opt/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin ...

~/.bash_profile , "". , python MacPorts Python, python_select, . , MacPorts - ; :

$ sudo rm -r /opt/local

MacPorts 10.6. . , , , , .

+5

, . , Python:

  • Apple Python 2.5.1 :/usr/bin/python
  • , :/Library/Frameworks/Python.framework/Versions/2.7
  • Macport, :/opt/local/bin/python2.6

:

$ python

2.7, Macports. :

$ sudo python_select python26

2.7, .

, Macports, :

$ PATH=$PATH\:/opt/local/bin ; export PATH

..

, scrapy-ctl.py , scrapy-ctl.py

/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/scrapy-ctl.py

UPDATE

, Scrapy (# 2 # 3).

# 2, " Scrapy Python"

sudo ln -s /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/scrapy-ctl.py /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scrapy

β„–3, " scrapy "

sudo ln -s /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/scrapy-ctl.py /usr/local/bin/scrapy
+1

, . :

sudo /opt/local/bin/easy_install-2.6 scrapy

AttributeError: 'NoneType' object has no attribute 'get'

Scrapy , .

,

cd /path/to/scrapy
sudo /opt/local/bin/python2.6 setup.py install

///scrapy? :

/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/scrapy-ctl.py

/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/Scrapy-0.8-py2.6.egg

- ?

0

@Ned Deily

, , , Scrapy 0.8 OS X 10.6. Macros Python 2.6, , . , Macports .

MacPorts :

http://www.macports.org/install.php

sudo port install py26-libxml2 py26-twisted py26-openssl py26-simplejson py26-setuptools python_select

sudo /opt/local/bin/easy_install-2.6 scrapy

~.profile :

export     PATH=/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:$PATH
0

Source: https://habr.com/ru/post/1734827/


All Articles