Issues with HA Presence Detection - Modul ping not found in virtualenv

Dear HA Community,

I have installed homeassistant in an python virtualenv environment and I would love to use Presence Detection. For that I configured the following in my configuration.yaml

device_tracker:
      - platform: ping
        interval_seconds: 90
        consider_home: 1200
        hosts:
          phone_1: 1.2.3.4
          phone_2: 5.6.7.8
          pc_1: 9.10.11.12
          pc_2: 13.14.15.16

Unfortunately it does not show up after an restart.
The following thing finds in the logfile:

2018-02-09 21:48:08 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform ping
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/__init__.py", line 169, in async_setup_platform
    disc_info)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/ping.py", line 89, in setup_scanner
    update_interval(None)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/ping.py", line 84, in update_interval
    host.update(see)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/ping.py", line 61, in update
    if self.ping():
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/device_tracker/ping.py", line 50, in ping
    stderr=subprocess.DEVNULL)
  File "/usr/lib/python3.5/subprocess.py", line 676, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.5/subprocess.py", line 1282, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'ping'

Which looks like the command “ping” is not found. I already tried to add the path of ping (/bin) the the homeassistants user path.
Then I tried to install “ping” via python pip which fails with the following error:

(homeassistant) homeassistant@homeassistant-01:/srv/homeassistant$ python3 -m pip install --no-cache-dir --upgrade ping
Collecting ping
  Downloading ping-0.2.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-idv5_9uq/ping/setup.py", line 23, in <module>
        from ping import __version__
      File "/tmp/pip-build-idv5_9uq/ping/ping.py", line 196
        except socket.error, (errno, msg):
                           ^
    SyntaxError: invalid syntax
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-idv5_9uq/ping/

Here is my question: How can I use “ping” in an virtualenv?
I also tried nmap, which also fails.

Maybe I think I should try hass.io ?

There might be some dependencies on the integration of “ping” here (which of course is installed), but I cant figure out which packages I need to install.

Hi, Did you ever resolve this? I am having the same issues.

Well, I changed my setup in the mean time a bit. I’m using hass.io now and further the device tracker component of my router (mikrotik) which works quiet good.

Eespecially for android phones the ping option is not that reliable.

OK Thanks Brandon.

Unlike your previous situation I can actually ping from the virtual environment and from the homeassistant user so I am not sure what is going on!