0

I am using python 3.1 and pip to install the packages. While instaling the same, I get error building wheels for lxml and numpy. Here's the error log :

Collecting widgetsnbextension==3.4.2
  Using cached widgetsnbextension-3.4.2-py2.py3-none-any.whl (2.2 MB)
Requirement already satisfied: setuptools>=18.5 in /home/sandeep/python_virtualenvs/projectkb/lib/python3.10/site-packages (from ipython==7.1.1->-r demo_requirementes.txt (line 9)) (45.0.0)
Building wheels for collected packages: lxml, numpy, pyzmq
  Building wheel for lxml (setup.py) ...
  
  src/lxml/etree.c:168998:3: note: in expansion of macro ‘__Pyx_TraceReturn’
      168998 |   __Pyx_TraceReturn(__pyx_r, 0);
             |   ^~~~~~~~~~~~~~~~~
      src/lxml/etree.c: In function ‘__pyx_f_4lxml_5etree__countNsDefs’:
      src/lxml/etree.c:5384:32: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘use_tracing’; did you mean ‘tracing’?
       5384 |           if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
            |                                ^~~~~~~~~~~
      src/lxml/etree.c:888:43: note: in definition of macro ‘unlikely’
        888 |   #define unlikely(x) __builtin_expect(!!(x), 0)
            |                                           ^
      src/lxml/etree.c:169020:3: note: in expansion of macro ‘__Pyx_TraceCall’
      169020 |   __Pyx_TraceCall("_countNsDefs", __pyx_f[13], 382, 0, __PYX_ERR(13, 382, __pyx_L1_error));
             |   ^~~~~~~~~~~~~~~
      src/lxml/etree.c:5393:28: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘use_tracing’; did you mean ‘tracing’?
       5393 |       if (unlikely(tstate->use_tracing) && !tstate->tracing &&\
            |                            ^~~~~~~~~~~
      src/lxml/etree.c:888:43: note: in definition of macro ‘unlikely’
        888 |   #define unlikely(x) __builtin_expect(!!(x), 0)
            |                                           ^
      src/lxml/etree.c:169020:3: note: in expansion of macro ‘__Pyx_TraceCall’
      169020 |   __Pyx_TraceCall("_countNsDefs", __pyx_f[13], 382, 0, __PYX_ERR(13, 382, __pyx_L1_error));
             |   ^~~~~~~~~~~~~~~
      src/lxml/etree.c:5451:27: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘use_tracing’; did you mean ‘tracing’?
       5451 |               if (tstate->use_tracing) {\
            |                           ^~~~~~~~~~~
      src/lxml/etree.c:169101:3: note: in expansion of macro ‘__Pyx_TraceReturn’
     
Compile failed: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitmnx27mzb.c -o tmp/xmlXPathInitmnx27mzb.o
      cc tmp/xmlXPathInitmnx27mzb.o -lxml2 -o a.out
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  Rolling back uninstall of lxml
  Moving to /home/sandeep/python_virtualenvs/projectkb/lib/python3.10/site-packages/lxml-4.9.1.dist-info/
   from /home/sandeep/python_virtualenvs/projectkb/lib/python3.10/site-packages/~xml-4.9.1.dist-info
  Moving to /home/sandeep/python_virtualenvs/projectkb/lib/python3.10/site-packages/lxml/
   from /home/sandeep/python_virtualenvs/projectkb/lib/python3.10/site-packages/~xml
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> lxml

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

Note : I even install lxml package, but that did not help.

What can I do to solve this issue? Thanks

Sandeep Kaur
  • 437
  • 3
  • 11
  • Is your problem somewhat related to the below quesions? https://stackoverflow.com/questions/5178416/libxml-install-error-using-pip https://stackoverflow.com/questions/62015991/python-building-wheel-for-lxml-setup-py-error – Amanjot Singh Oct 06 '22 at 06:54
  • Just tried installing `lxml` on Python 3.10.6 and pip 22.2.2, ``` $ pip install lxml Collecting lxml Downloading lxml-4.9.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (6.9 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.9/6.9 MB 4.1 MB/s eta 0:00:00 Installing collected packages: lxml Successfully installed lxml-4.9.1 ``` If you have any specific package that you are trying to install, mentioning that may help. – Mandeep Singh Oct 06 '22 at 07:00
  • @AmanjotSingh I tried this, python3-lxml get installed, but error persists. – Sandeep Kaur Oct 06 '22 at 07:02
  • @MandeepSingh Yes, there is no problem with installing lxml using pip, but while installing widgetsnbextension, it builds wheel for lxml, where after having lxml already installed it tries to uninstall it and install new one, thus generating this error, it seems there is some problem with c files. – Sandeep Kaur Oct 06 '22 at 07:04
  • @SandeepKaur, I just tried installing `widgetsnbextension` (`pip install widgetsnbextension`) and it got installed within a seccond. Possibly your requirements.txt has some old version of lxml mentioned which may not be compatible with your current Python version. Is installing `widgetsnbextension` directly with pip working for you (may try in a new virtualenv)? – Mandeep Singh Oct 06 '22 at 07:08

1 Answers1

1

As the installation of the mentioned dependencies is working fine, the problem seems like there are older versions of those dependencies mentioned in your requirements.txt file. The error might be due to incompatibility of those older dependencies' versions and your current Python environment.

  • One way to fix this is to remove the package version in your requirements.txt file e.g. if we have lxml==4.2, we can strip the version and keep just lxml in that file. Similarly for other dependencies. Can use this regex to strip the versions:
sed 's/==.*//' requirements.txt > requirements_new.txt
pip freeze > requirements-new.txt

Please let me know if you face any other issue related to this.