I'm getting an error installing an older version of lxml on my computer.
I've created a new virtual environment in an empty project to try to isolate the error.
(env) ~/Desktop/lxml-3.8.0-test$ pip install lxml==3.8.0 --log log.txt
Collecting lxml==3.8.0
Using cached https://files.pythonhosted.org/packages/20/b3/9f245de14b7696e2d2a386c0b09032a2ff6625270761d6543827e667d8de/lxml-3.8.0.tar.gz
Installing collected packages: lxml
Running setup.py install for lxml ... error
ERROR: Command errored out with exit status 1: /Users/ceasar/Desktop/lxml-3.8.0-test/env/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/hs/mywxk87n21q3rdbyfn24t6v80000gn/T/pip-install-r_dh7_0_/lxml/setup.py'"'"'; __file__='"'"'/private/var/folders/hs/mywxk87n21q3rdbyfn24t6v80000gn/T/pip-install-r_dh7_0_/lxml/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/hs/mywxk87n21q3rdbyfn24t6v80000gn/T/pip-record-io8knvww/install-record.txt --single-version-externally-managed --compile --install-headers /Users/ceasar/Desktop/lxml-3.8.0-test/env/include/site/python3.8/lxml Check the logs for full command output.
The installation page for lxml suggests using STATIC_DEPS=true
which makes the setup.py
for lxml down and build the latest versions of libxml2
and libxslt
instead of using the system version. 1 However, this didn't help:
(env) ~/Desktop/lxml-3.8.0-test$ STATIC_DEPS=true sudo pip install lxml==3.8.0 --log log.txt
Password:
WARNING: The directory '/Users/ceasar/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/Users/ceasar/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting lxml==3.8.0
Downloading https://files.pythonhosted.org/packages/20/b3/9f245de14b7696e2d2a386c0b09032a2ff6625270761d6543827e667d8de/lxml-3.8.0.tar.gz (3.8MB)
|████████████████████████████████| 3.8MB 4.5MB/s
Installing collected packages: lxml
Running setup.py install for lxml ... error
ERROR: Command errored out with exit status 1: /Users/ceasar/Desktop/lxml-3.8.0-test/env/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-osbo4ix7/lxml/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-osbo4ix7/lxml/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-0orpd_yt/install-record.txt --single-version-externally-managed --compile --install-headers /Users/ceasar/Desktop/lxml-3.8.0-test/env/include/site/python3.8/lxml Check the logs for full command output.
The log file looks like this:
...
2021-09-16T10:07:15,323 creating build/temp.macosx-10.14.6-x86_64-3.8/src/lxml
2021-09-16T10:07:15,323 clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/S
ystem.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -Werror=i
mplicit-function-declaration -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -Isrc/lxml/includes -I/Users/ceasar/Desktop/lxml-3.8.0-test/env/include -I/Library/D
eveloper/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c src/lxml/lxml.etree.c -o build/temp.macosx-10.14.6-x86_64-3.8/src/lxml/lxml.etree.
o -w -flat_namespace
2021-09-16T10:07:16,822 src/lxml/lxml.etree.c:233279:65: error: too many arguments to function call, expected 3, have 4
2021-09-16T10:07:16,822 return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL);
2021-09-16T10:07:16,822 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^~~~
...
2021-09-16T10:07:16,831 /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8/cpython/pystate.h:79:15: note: 'curexc_value' declared here
2021-09-16T10:07:16,831 PyObject *curexc_value;
2021-09-16T10:07:16,831 ^
2021-09-16T10:07:16,831 fatal error: too many errors emitted, stopping now [-ferror-limit=]
2021-09-16T10:07:16,872 20 errors generated.
2021-09-16T10:07:16,884 Compile failed: command 'clang' failed with exit status 1
2021-09-16T10:07:16,942 creating tmp
2021-09-16T10:07:16,942 cc -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/usr/include/libxml2 -c /tmp/xmlXPathInituaq3ydct.c -o tmp/xmlXPathInituaq3ydct.o
2021-09-16T10:07:17,005 cc tmp/xmlXPathInituaq3ydct.o -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lxml2 -o a.out
2021-09-16T10:07:17,091 error: command 'clang' failed with exit status 1
I'm not sure where to go from here. I found some similar questions, which were no help:
- Install lxml on MacOS Big Sur (11.3.1) (no answer, and also trying to install the latest version)
- Cannot install Lxml on Mac OS X 10.9 (various solutions which I tried, but didn't have any success with)
I don't have much knowledge of macOS, C, or compilers, so I'm not sure how to make sense of this error. What can I do to make progress getting this installed?