Ubuntu22.04 Windows10安装netifaces失败的问题

执行命令pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com/simple syft hagrid来安装pysyft和hagrid,但是卡在了netifaces上,重新pip install nerifaces,依旧报出相同的问题

$ pip install netifaces==0.11.0
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting netifaces==0.11.0
  Using cached https://mirrors.aliyun.com/pypi/packages/a6/91/86a6eac449ddfae239e93ffc1918cf33fd9bab35c04d1e963b311e347a73/netifaces-0.11.0.tar.gz (30 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: netifaces
  Building wheel for netifaces (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [17 lines of output]
      /home/rogz/anaconda3/envs/syft/lib/python3.10/site-packages/setuptools/config/setupcfg.py:463: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead.
        warnings.warn(msg, warning_class)
      running bdist_wheel
      running build
      running build_ext
      checking for getifaddrs...not found.
      checking for getnameinfo...not found.
      checking for socket IOCTLs...not found.
      checking for optional header files...none found.
      checking whether struct sockaddr has a length field...no.
      checking which sockaddr_xxx structs are defined...none!
      checking for routing socket support...no.
      checking for sysctl(CTL_NET...) support...no.
      checking for netlink support...no.
      building 'netifaces' extension
      gcc -pthread -B /home/rogz/anaconda3/envs/syft/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -fPIC -O2 -isystem /home/rogz/anaconda3/envs/syft/include -fPIC -O2 -isystem /home/rogz/anaconda3/envs/syft/include -fPIC -DNETIFACES_VERSION=0.11.0 -I/home/rogz/anaconda3/envs/syft/include/python3.10 -c netifaces.c -o build/temp.linux-x86_64-cpython-310/netifaces.o
      error: command 'gcc' failed: No such file or directory
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for netifaces
  Running setup.py clean for netifaces
Failed to build netifaces
Installing collected packages: netifaces
  Running setup.py install for netifaces ... error
  error: subprocess-exited-with-error
  
  × Running setup.py install for netifaces did not run successfully.
  │ exit code: 1
  ╰─> [19 lines of output]
      /home/rogz/anaconda3/envs/syft/lib/python3.10/site-packages/setuptools/config/setupcfg.py:463: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead.
        warnings.warn(msg, warning_class)
      running install
      /home/rogz/anaconda3/envs/syft/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_ext
      checking for getifaddrs...not found.
      checking for getnameinfo...not found.
      checking for socket IOCTLs...not found.
      checking for optional header files...none found.
      checking whether struct sockaddr has a length field...no.
      checking which sockaddr_xxx structs are defined...none!
      checking for routing socket support...no.
      checking for sysctl(CTL_NET...) support...no.
      checking for netlink support...no.
      building 'netifaces' extension
      gcc -pthread -B /home/rogz/anaconda3/envs/syft/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -fPIC -O2 -isystem /home/rogz/anaconda3/envs/syft/include -fPIC -O2 -isystem /home/rogz/anaconda3/envs/syft/include -fPIC -DNETIFACES_VERSION=0.11.0 -I/home/rogz/anaconda3/envs/syft/include/python3.10 -c netifaces.c -o build/temp.linux-x86_64-cpython-310/netifaces.o
      error: command 'gcc' failed: No such file or directory
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

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

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


解决方法:
Ubuntu:
根据输出,是gcc出现了问题,没有文件,安装gcc库,即可解决
sudo apt install build-essential

Windows:
https://visualstudio.microsoft.com/zh-hans/downloads/#:~:text=Visual%20Studio%202022%20%E7%94%9F%E6%88%90%E5%B7%A5%E5%85%B7
在当前网页找到Visual Studio 2022 生成工具,下载安装即可解决

posted @ 2022-09-28 10:20  RogZ  阅读(1762)  评论(0编辑  收藏  举报