Home > Enterprise >  Error while installing widgetsnbextension using pip
Error while installing widgetsnbextension using pip

Time:10-06

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

CodePudding user response:

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.

  • Related