molobrakos / volvooncall

Retrieve information from the Volvo On Call (VOC) web service
The Unlicense
158 stars 51 forks source link

Syntax Error #18

Closed chixxi closed 6 years ago

chixxi commented 6 years ago

First off, thanks for the work you have done. I do own a Volvo XC90 and I'd love to write a driver for it that works with NEEO.

I did clone, then build and install, but I am honestly no pro. I am assuming I am doing something wrong rather then you actually having published a syntax error.

Would be lovely if you could hint me in the right directon. This is the error I am getting:

pi@raspiTR2ImageFTP:~/volvooncall $ voc --version Traceback (most recent call last): File "/usr/local/bin/voc", line 4, in <module> __import__('pkg_resources').run_script('volvooncall==0.5.0', 'voc') File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 534, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1444, in run_script script_code = compile(script_text, script_filename,'exec') File "/usr/local/lib/python2.7/dist-packages/volvooncall-0.5.0-py2.7.egg/EGG-INFO/scripts/voc", line 208 print(f'{instrument}: {instrument.str_state}') ^ SyntaxError: invalid syntax

chixxi commented 6 years ago

Should that already be somewhere or do I have to create that myself? $HOME/.voc.conf:

chixxi commented 6 years ago

Oh, is Python 3.7 required? Currently using Python 2.7.9 and Python 3.4.2

molobrakos commented 6 years ago

At least Python 3.6 is currently required

molobrakos commented 6 years ago

voc.conf is where you can put your username/password if you don't want to pass them every time.

chixxi commented 6 years ago

So I did install python 3.7.0 as well as pip3 and setup-tools for python3. I then did an alias for python=python3.7 to make sure python3 is used during the installation of VOC.

I then did sudo python setup.py build sudo python setup.py install

During the install I get this error: `ext/_yaml.h:2:18: fatal error: yaml.h: No such file or directory

include

              ^`

The installation is successful though, but when trying to use VOC I always get the same error still: pi@raspberrypi:~/volvooncall $ voc --help Traceback (most recent call last): File "/usr/local/bin/voc", line 4, in <module> __import__('pkg_resources').run_script('volvooncall==0.5.0', 'voc') File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 739, in run_script self.require(requires)[0].run_script(script_name, ns) File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1500, in run_script script_code = compile(script_text, script_filename, 'exec') File "/usr/local/lib/python2.7/dist-packages/volvooncall-0.5.0-py2.7.egg/EGG-INFO/scripts/voc", line 208 print(f'{instrument}: {instrument.str_state}') ^ SyntaxError: invalid syntax

I somehow have the feeling that the wrong python version is used during build, installation and usage. Any ideas how I can specify that?

molobrakos commented 6 years ago

What about just pip3 install volvooncall?

chixxi commented 6 years ago

This way of installation fails cause it can't find requirements.txt. Here is what I did exactly.

  1. Setup a completely new SD with raspian.
  2. Installed python 3.7.0:
    wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
    tar xf Python-3.6.5.tar.xz
    cd Python-3.7.0
    ./configure
    make
    sudo make altinstall
  3. Installed pip3 sudo apt-get install python3-pip
  4. Tried installing voc, now running into this error:

    
    pi@raspberrypi:~ $ pip3 install volvooncall
    Collecting volvooncall
    Downloading https://files.pythonhosted.org/packages/d7/6a/f510becddb548d540b68a8b27023d37971e6f8f832e85188bb007097aa44/volvooncall-0.5.0.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-9opkevw2/volvooncall/setup.py", line 16, in <module>
        open('requirements.txt').read().strip().split('\n')),
    FileNotFoundError: [Errno 2] No such file or directory: 'requirements.txt'
    
    ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-9opkevw2/volvooncall/
chixxi commented 6 years ago

I was not yet able to install successfully, tried to start manually, but even then I ran into the same syntax error:

pi@raspberrypi:~/volvooncall $ ./voc --version File "./voc", line 208 print(f'{instrument}: {instrument.str_state}') ^ SyntaxError: invalid syntax

chixxi commented 6 years ago

So I thought, well then just add requirments.txt to the archive, then I get this:

Processing /home/pi/volvooncall-0.5.0
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-xl1afi5k-build/setup.py", line 16, in <module>
        open('requirements.txt').read().strip().split('\n')),
      File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
        return codecs.ascii_decode(input, self.errors)[0]
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 1487: ordinal not in range(128)

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-xl1afi5k-build/

Do I interpret correctly that pip3 is using the wrong python (3.5) version? (/usr/lib/python3.5/encodings/ascii.py)

chixxi commented 6 years ago

So I thought I need to try another place since python and pip on the raspberry seem to be a huge mess. So I installed python3.7 on my mac, same thing:

XY-Laptop:~ XY$ pip3.7 install volvooncall
Collecting volvooncall
  Downloading https://files.pythonhosted.org/packages/d7/6a/f510becddb548d540b68a8b27023d37971e6f8f832e85188bb007097aa44/volvooncall-0.5.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/ch/x35z9gpx20lfpvz9kj47fpdw0000gn/T/pip-install-m23qgprv/volvooncall/setup.py", line 16, in <module>
        open('requirements.txt').read().strip().split('\n')),
    FileNotFoundError: [Errno 2] No such file or directory: 'requirements.txt'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/ch/x35z9gpx20lfpvz9kj47fpdw0000gn/T/pip-install-m23qgprv/volvooncall/

Then I unpacked the archive and moved requirex.txt one level further up, next error:

XY-Laptop:~ XY$ pip3.7 install Downloads/volvooncall-0.5.0/
Processing ./Downloads/volvooncall-0.5.0
    Complete output from command python setup.py egg_info:
    error in volvooncall setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers; Invalid requirement, parse error at "'[console'"

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/ch/x35z9gpx20lfpvz9kj47fpdw0000gn/T/pip-req-build-cnlb8_0n/

Giving up, I have no more further ideas on what I could try.

propyless commented 6 years ago

Try pip3 install git+https://github.com/molobrakos/volvooncall.git

*propyless@home ~/repos/test $ mkvirtualenv -p /usr/bin/python3.6 voc-test*
Running virtualenv with interpreter /usr/bin/python3.6
Using base prefix '/usr'
New python executable in /home/propyless/.virtualenvs/voc-test/bin/python3.6
Also creating executable in /home/propyless/.virtualenvs/voc-test/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating
/home/propyless/.virtualenvs/voc-test/bin/predeactivate
virtualenvwrapper.user_scripts creating
/home/propyless/.virtualenvs/voc-test/bin/postdeactivate
virtualenvwrapper.user_scripts creating
/home/propyless/.virtualenvs/voc-test/bin/preactivate
virtualenvwrapper.user_scripts creating
/home/propyless/.virtualenvs/voc-test/bin/postactivate
virtualenvwrapper.user_scripts creating
/home/propyless/.virtualenvs/voc-test/bin/get_env_details
(voc-test) propyless@home ~/repos/test $
(voc-test) propyless@home ~/repos/test $
*(voc-test) propyless@home ~/repos/test $ which pip3*
/home/propyless/.virtualenvs/voc-test/bin/pip3

*(voc-test) propyless@home ~/repos/test $ pip3 install
git+https://github.com/molobrakos/volvooncall.git
<https://github.com/molobrakos/volvooncall.git>*
Collecting git+https://github.com/molobrakos/volvooncall.git
  Cloning https://github.com/molobrakos/volvooncall.git to
/tmp/pip-req-build-feowxcvd
Collecting requests (from volvooncall==0.5.0)
  Downloading
https://files.pythonhosted.org/packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl
(91kB)
    100% |████████████████████████████████| 92kB 4.5MB/s
Requirement already satisfied: setuptools in
/home/propyless/.virtualenvs/voc-test/lib/python3.6/site-packages (from
volvooncall==0.5.0) (39.2.0)
Collecting paho-mqtt (from volvooncall==0.5.0)
  Downloading
https://files.pythonhosted.org/packages/2a/5f/cf14b8f9f8ed1891cda893a2a7d1d6fa23de2a9fb4832f05cef02b79d01f/paho-mqtt-1.3.1.tar.gz
(80kB)
    100% |████████████████████████████████| 81kB 2.8MB/s
Collecting geopy (from volvooncall==0.5.0)
  Downloading
https://files.pythonhosted.org/packages/9b/1b/f63484e2c257a79f9fed6243f638d0fc50566428b87994dbf2cdf681a05e/geopy-1.14.0-py2.py3-none-any.whl
(77kB)
    100% |████████████████████████████████| 81kB 2.9MB/s
Collecting docopt (from volvooncall==0.5.0)
  Downloading
https://files.pythonhosted.org/packages/a2/55/8f8cab2afd404cf578136ef2cc5dfb50baa1761b68c9da1fb1e4eed343c9/docopt-0.6.2.tar.gz
Collecting pyyaml (from volvooncall==0.5.0)
  Downloading
https://files.pythonhosted.org/packages/4a/85/db5a2df477072b2902b0eb892feb37d88ac635d36245a72a6a69b23b383a/PyYAML-3.12.tar.gz
(253kB)
    100% |████████████████████████████████| 256kB 1.3MB/s
Collecting certifi (from volvooncall==0.5.0)
  Using cached
https://files.pythonhosted.org/packages/7c/e6/92ad559b7192d846975fc916b65f667c7b8c3a32bea7372340bfe9a15fa5/certifi-2018.4.16-py2.py3-none-any.whl
Collecting urllib3<1.24,>=1.21.1 (from requests->volvooncall==0.5.0)
  Downloading
https://files.pythonhosted.org/packages/bd/c9/6fdd990019071a4a32a5e7cb78a1d92c53851ef4f56f62a3486e6a7d8ffb/urllib3-1.23-py2.py3-none-any.whl
(133kB)
    100% |████████████████████████████████| 143kB 999kB/s
Collecting idna<2.8,>=2.5 (from requests->volvooncall==0.5.0)
  Downloading
https://files.pythonhosted.org/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl
(58kB)
    100% |████████████████████████████████| 61kB 1.3MB/s
Collecting chardet<3.1.0,>=3.0.2 (from requests->volvooncall==0.5.0)
  Using cached
https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Collecting geographiclib<2,>=1.49 (from geopy->volvooncall==0.5.0)
  Downloading
https://files.pythonhosted.org/packages/5b/ac/4f348828091490d77899bc74e92238e2b55c59392f21948f296e94e50e2b/geographiclib-1.49.tar.gz
Building wheels for collected packages: volvooncall, paho-mqtt, docopt,
pyyaml, geographiclib
  Running setup.py bdist_wheel for volvooncall ... done
  Stored in directory:
/tmp/pip-ephem-wheel-cache-q_nucupy/wheels/b0/6b/42/30ad199f7a9df68afcc322ccbfb5bc0d1c915de2596706badc
  Running setup.py bdist_wheel for paho-mqtt ... done
  Stored in directory:
/home/propyless/.cache/pip/wheels/38/ca/67/86c7e4acc659ce5ab74cbb8cc38de50c90ed4f827133e36994
  Running setup.py bdist_wheel for docopt ... done
  Stored in directory:
/home/propyless/.cache/pip/wheels/9b/04/dd/7daf4150b6d9b12949298737de9431a324d4b797ffd63f526e
  Running setup.py bdist_wheel for pyyaml ... done
  Stored in directory:
/home/propyless/.cache/pip/wheels/03/05/65/bdc14f2c6e09e82ae3e0f13d021e1b6b2481437ea2f207df3f
  Running setup.py bdist_wheel for geographiclib ... done
  Stored in directory:
/home/propyless/.cache/pip/wheels/99/45/d1/14954797e2a976083182c2e7da9b4e924509e59b6e5c661061
Successfully built volvooncall paho-mqtt docopt pyyaml geographiclib
Installing collected packages: urllib3, certifi, idna, chardet, requests,
paho-mqtt, geographiclib, geopy, docopt, pyyaml, volvooncall
Successfully installed certifi-2018.4.16 chardet-3.0.4 docopt-0.6.2
geographiclib-1.49 geopy-1.14.0 idna-2.7 paho-mqtt-1.3.1 pyyaml-3.12
requests-2.19.1 urllib3-1.23 volvooncall-0.5.0
chixxi commented 6 years ago

NICE!!! Thank you so much, that got it running on my Macbook Pro.