python-miio icon indicating copy to clipboard operation
python-miio copied to clipboard

Installation on windows fails without netifaces (optional) dependency

Open euronion opened this issue 4 years ago • 7 comments

I am unable to install python-miio on windows. I do not have Microsoft Visual C++ 14.0 (or greater) installed, thus the installation fails when trying to install netifaces.

As I understood it netifaces should be an optional dependency and not be required for the installation on Windows since release 0.5.5 (#964 ).

Version information (please complete the following information):

  • OS: Windows 10 Pro 20H2
  • python-miio: None (unable to install)

Device information: n/a

To Reproduce Steps to reproduce the behavior (I am using conda and mamba instead of virtualenv):

conda create --name miio
conda activate miio
mamba install -c conda-forge python pip wheel
pip install python-miio

Expected behavior python-miio should be installed without netifaces being required.

Console output

Expand here
(miio) C:\Users\<USER>>pip install python-miio
Collecting python-miio
  Using cached python_miio-0.5.5.2-py3-none-any.whl (267 kB)
Collecting android_backup<1,>=0
  Using cached android_backup-0.2.0-py3-none-any.whl
Collecting attrs
  Using cached attrs-20.3.0-py2.py3-none-any.whl (49 kB)
Collecting tqdm<5,>=4
  Using cached tqdm-4.60.0-py2.py3-none-any.whl (75 kB)
Collecting construct<3.0.0,>=2.10.56
  Using cached construct-2.10.67-py3-none-any.whl
Collecting defusedxml<0.7,>=0.6
  Using cached defusedxml-0.6.0-py2.py3-none-any.whl (23 kB)
Collecting zeroconf<0.29,>=0.28
  Using cached zeroconf-0.28.8-py3-none-any.whl (55 kB)
Collecting cryptography<4,>=3
  Using cached cryptography-3.4.7-cp36-abi3-win_amd64.whl (1.6 MB)
Collecting appdirs<2,>=1
  Using cached appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)
Collecting PyYAML<6,>=5
  Using cached PyYAML-5.4.1-cp39-cp39-win_amd64.whl (213 kB)
Collecting click<8,>=7
  Using cached click-7.1.2-py2.py3-none-any.whl (82 kB)
Collecting pytz
  Using cached pytz-2021.1-py2.py3-none-any.whl (510 kB)
Collecting croniter<1,>=0
  Using cached croniter-0.3.37-py2.py3-none-any.whl (13 kB)
Collecting netifaces<1,>=0
  Using cached netifaces-0.10.9.tar.gz (28 kB)
Collecting python-dateutil
  Using cached python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Collecting natsort
  Using cached natsort-7.1.1-py3-none-any.whl (35 kB)
Collecting cffi>=1.12
  Using cached cffi-1.14.5-cp39-cp39-win_amd64.whl (179 kB)
Collecting pycparser
  Using cached pycparser-2.20-py2.py3-none-any.whl (112 kB)
Collecting ifaddr>=0.1.7
  Using cached ifaddr-0.1.7-py2.py3-none-any.whl (10 kB)
Collecting six>=1.5
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Building wheels for collected packages: netifaces
  Building wheel for netifaces (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\anaconda\envs\miio\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\<USER>\\AppData\\Local\\Temp\\pip-install-0umu1zai\\netifaces_0c685e1d61f44e77a2db8efd3aa4422d\\setup.py'"'"'; __file__='"'"'C:\\Users\\<USER>\\AppData\\Local\\Temp\\pip-install-0umu1zai\\netifaces_0c685e1d61f44e77a2db8efd3aa4422d\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\<USER>\AppData\Local\Temp\pip-wheel-6fpjjnyp'
       cwd: C:\Users\<USER>\AppData\Local\Temp\pip-install-0umu1zai\netifaces_0c685e1d61f44e77a2db8efd3aa4422d\
  Complete output (5 lines):
  running bdist_wheel
  running build
  running build_ext
  building 'netifaces' extension
  error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
  ----------------------------------------
  ERROR: Failed building wheel for netifaces
  Running setup.py clean for netifaces
Failed to build netifaces
Installing collected packages: six, pycparser, python-dateutil, natsort, ifaddr, cffi, zeroconf, tqdm, PyYAML, pytz, netifaces, defusedxml, cryptography, croniter, construct, click, attrs, appdirs, android-backup, python-miio
    Running setup.py install for netifaces ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\anaconda\envs\miio\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\<USER>\\AppData\\Local\\Temp\\pip-install-0umu1zai\\netifaces_0c685e1d61f44e77a2db8efd3aa4422d\\setup.py'"'"'; __file__='"'"'C:\\Users\\<USER>\\AppData\\Local\\Temp\\pip-install-0umu1zai\\netifaces_0c685e1d61f44e77a2db8efd3aa4422d\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\<USER>\AppData\Local\Temp\pip-record-3rall3rl\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\anaconda\envs\miio\Include\netifaces'
         cwd: C:\Users\<USER>\AppData\Local\Temp\pip-install-0umu1zai\netifaces_0c685e1d61f44e77a2db8efd3aa4422d\
    Complete output (5 lines):
    running install
    running build
    running build_ext
    building 'netifaces' extension
    error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\anaconda\envs\miio\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\<USER>\\AppData\\Local\\Temp\\pip-install-0umu1zai\\netifaces_0c685e1d61f44e77a2db8efd3aa4422d\\setup.py'"'"'; __file__='"'"'C:\\Users\\<USER>\\AppData\\Local\\Temp\\pip-install-0umu1zai\\netifaces_0c685e1d61f44e77a2db8efd3aa4422d\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\<USER>\AppData\Local\Temp\pip-record-3rall3rl\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\anaconda\envs\miio\Include\netifaces' Check the logs for full command output.

euronion avatar May 02 '21 19:05 euronion

Ohh, looks like this might be a bug in poetry: https://github.com/python-poetry/poetry/issues/2357 . ~~Could you try to install from the source package using pip install python-miio --no-binary python-miio to see if that works? It seems to be terribly slow though, likely related to the rust dependency (#997)..~~

edit: looks like that is not working either, this needs some more investigation, but optional dependencies should definitely not be required to install the package :-(

rytilahti avatar May 03 '21 19:05 rytilahti

Ahh, that's unfortunate but I guess nothing we can do about it? (I'll head out and install Visual C++ in the meantime.)

euronion avatar May 03 '21 20:05 euronion

That will need some investigation, but I hope a solution can be found.

rytilahti avatar May 03 '21 21:05 rytilahti

@euronion I just realized that disabling the dependency installation (--no-deps) as mentioned in the original issue can be used as a workaround (that's how I tested that the lib itself works instead of installing the vc++). The netifaces is only used in a single place in the code (the updater uses it to find the interface for binding, iirc), so it shouldn't hinder any other uses.

rytilahti avatar May 05 '21 20:05 rytilahti

That's an amazingly simple workaround! Thanks, worked like a charm.

euronion avatar May 06 '21 05:05 euronion

Its still not fixed and its extremely frustrating

thelittleerik avatar May 17 '24 15:05 thelittleerik

@thelittleerik are you sure? #1738 should have actually fixed this for good, but there has been no releases since then, so you'd need to use the current master branch checkout or do pip install --pre python-miio (which installs the pre-release).

rytilahti avatar May 18 '24 00:05 rytilahti