Help installing USPS component

So the USPS component works again and now for the RPI is requires phantomjs. I can’t seem to figure out how to install that. Here is the USPS component: https://home-assistant.io/components/usps/. I would assume I need the Linux version. When I download the tar or zip file those are just cpp/c files and the binary doesn’t seem to work on the RPI. Any suggestions or help?

Edit: Looks like I’m not the only one. I used this to install phantomjs: https://www.reddit.com/r/homeassistant/comments/80a98w/064_over_1000_integrations_new_homekit_bmw_august/duv6685/

but now I am getting this error:

Error during setup of component usps
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/setup.py", line 148, in _async_setup_component
    component.setup, hass, processed_config)
  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/usps.py", line 49, in setup
    import myusps
  File "/srv/homeassistant/lib/python3.5/site-packages/myusps/__init__.py", line 12, in <module>
    import requests_cache
  File "/srv/homeassistant/lib/python3.5/site-packages/requests_cache/__init__.py", line 28, in <module>
    from .core import(
  File "/srv/homeassistant/lib/python3.5/site-packages/requests_cache/core.py", line 21, in <module>
    ver = tuple(map(int, requests.__version__.split(".")))
AttributeError: module 'pip._vendor.requests.__version__' has no attribute 'split'

Stop HASS, then from your virtual environment execute: pip3 install --upgrade myusps==1.3.2 then start HASS again.

I’m actually in the same boat. I’m using Hassio instead of Hassbian. Not sure how to get PhantomJS installed. I tried pip3 install --upgrade myusps==1.3.2 from an SSH session but no luck.

I believe I did that. I’m using hassbian. So I impersonated into homeassistant and upgraded. I also verified in the usps.py file that is was using the correct version.

Not sure I moved away from hassio for this reason. If something breaks you’re screwed and you have no control.

So far for me this is the only thing that has broken that I’m having a time fixing. That and it seems Fedex has also broken…

Yeah same here I replied to an existing thread and put in a github issue: Fedex: Error on device update!

Not sure if anyone has come up with anything for Hass.io. I was thinking of switching to Hassbian but this is literally the only thing that won’t work for me. Don’t want to switch just for that but it is something I use daily on my phone.

1 Like

Any updates on this? I’m hoping to use USPS on HASSIO

1 Like

This worked for me. I’m running Hass.io on a Hyper-V VM and had to run the commands from the client diretly - running the commands through one of the SSH add-ons did not work. I assume with a RPi one could plug a monitor and keyboard in directly.

  1. Open a shell in the homeassistant container
    sudo docker exec -i -t homeassistant /bin/bash

  2. Install Chrome
    apk --update add chromium

  3. Install Chromedriver
    apk --update add chromium-chromedriver

  4. Add google-chrome symlink (we installed chromium, which is technically different than chrome, and I assume the USPS component looks for google-chrome)
    cp -av /usr/bin/chromium-browser /usr/bin/google-chrome

Then you should just have to set up the USPS component with the driver: chrome option

EDIT: I know the component documentation states that PhantomJS must be used on a RPi but I’m not sure that’s true with Hass.io. The homeassistant docker container runs Arctic Linux, which I assume is the same on the RPi and chromium is available…I assume this is the same on an RPi as that’s the point of Docker containers.

Thanks for that edit, I may give this a try shortly as I would like to get the component installed.

By the way, changes to the docker container won’t persist across a host reboot unless the container is commited, and I assume that a Home Assistant update simply loads a new container. So it’s probably easiest to just create a shell_command and have an automation run it at homeassistant start. This is how I have it set up:

shell_command:
  setup_usps: apk --update add chromium chromium-chromedriver && cp -av /usr/bin/chromium-browser /usr/bin/google-chrome
1 Like

So I tried @claytonjn’s process and I can see the version when I use chromedriver --version. However; HASS is still showing the following error in the logs:

Error handling request
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/myusps/init.py”, line 207, in wrapped
return function(*args)
File “/usr/lib/python3.6/site-packages/myusps/init.py”, line 237, in get_packages
response = _get_dashboard(session)
File “/usr/lib/python3.6/site-packages/myusps/init.py”, line 198, in _get_dashboard
raise USPSError(‘expired session’)
myusps.USPSError: expired session

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/selenium/webdriver/common/service.py”, line 76, in start
stdin=PIPE)
File “/usr/lib/python3.6/subprocess.py”, line 709, in init
restore_signals, start_new_session)
File “/usr/lib/python3.6/subprocess.py”, line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: ‘chromedriver’: ‘chromedriver’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/myusps/init.py”, line 170, in _login
driver = _get_driver(session.auth.driver)
File “/usr/lib/python3.6/site-packages/myusps/init.py”, line 149, in _get_driver
return webdriver.Chrome(chrome_options=chrome_options)
File “/usr/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py”, line 68, in init
self.service.start()
File “/usr/lib/python3.6/site-packages/selenium/webdriver/common/service.py”, line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: ‘chromedriver’ executable needs to be in PATH. Please see Sign in - Google Accounts

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/aiohttp/web_protocol.py”, line 381, in start
resp = await self._request_handler(request)
File “/usr/lib/python3.6/site-packages/aiohttp/web_app.py”, line 322, in _handle
resp = await handler(request)
File “/usr/lib/python3.6/site-packages/aiohttp/web_middlewares.py”, line 88, in impl
return await handler(request)
File “/usr/lib/python3.6/site-packages/homeassistant/components/http/static.py”, line 68, in staticresource_middleware
return await handler(request)
File “/usr/lib/python3.6/site-packages/homeassistant/components/http/real_ip.py”, line 27, in real_ip_middleware
return await handler(request)
File “/usr/lib/python3.6/site-packages/homeassistant/components/http/ban.py”, line 68, in ban_middleware
return await handler(request)
File “/usr/lib/python3.6/site-packages/homeassistant/components/http/auth.py”, line 52, in auth_middleware
return await handler(request)
File “/usr/lib/python3.6/site-packages/homeassistant/components/http/view.py”, line 104, in handle
result = await result
File “/usr/lib/python3.6/site-packages/homeassistant/components/camera/init.py”, line 379, in get
response = yield from self.handle(request, camera)
File “/usr/lib/python3.6/site-packages/homeassistant/components/camera/init.py”, line 399, in handle
image = yield from camera.async_camera_image()
File “/usr/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/lib/python3.6/site-packages/homeassistant/components/camera/usps.py”, line 49, in camera_image
self._usps.update()
File “/usr/lib/python3.6/site-packages/homeassistant/util/init.py”, line 319, in wrapper
result = method(*args, **kwargs)
File “/usr/lib/python3.6/site-packages/homeassistant/components/usps.py”, line 87, in update
self.packages = myusps.get_packages(self.session)
File “/usr/lib/python3.6/site-packages/myusps/init.py”, line 210, in wrapped
_login(args[0])
File “/usr/lib/python3.6/site-packages/myusps/init.py”, line 172, in _login
raise USPSError(str(exception))
myusps.USPSError: Message: ‘chromedriver’ executable needs to be in PATH. Please see Sign in - Google Accounts

Same for me :confused:

Same for me as well. I spent a few hours trying to find a workaround too but got nowhere.