Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error running ve/bin/pip bin/srv.py #296

Closed
j75 opened this issue May 6, 2019 · 22 comments
Closed

error running ve/bin/pip bin/srv.py #296

j75 opened this issue May 6, 2019 · 22 comments

Comments

@j75
Copy link

j75 commented May 6, 2019

I was following the README :

$ ve/bin/pip bin/srv.py 
ERROR: unknown command "bin/srv.py"

However, bin/srv.py exists:

$ tree bin
bin
├── proxy.py
└── srv.py

0 directories, 2 files

How should I proceed further?

@chubin
Copy link
Owner

chubin commented May 6, 2019

@j75 It's a bug in the documentation of course, it should be ve/bin/python not pip

@chubin chubin closed this as completed May 6, 2019
chubin added a commit that referenced this issue May 6, 2019
@j75
Copy link
Author

j75 commented May 7, 2019

$ ve/bin/python bin/srv.py
Traceback (most recent call last):
  File "bin/srv.py", line 20, in <module>
    import wttr_srv
  File "/home/pula/public_html/wttr.in/ve/local/lib/python2.7/site-packages/gevent/builtins.py", line 96, in __import__
    result = _import(*args, **kwargs)
  File "/home/pula/public_html/wttr.in/lib/wttr_srv.py", line 13, in <module>
    import wttrin_png
  File "/home/pula/public_html/wttr.in/ve/local/lib/python2.7/site-packages/gevent/builtins.py", line 96, in __import__
    result = _import(*args, **kwargs)
  File "/home/pula/public_html/wttr.in/lib/wttrin_png.py", line 22, in <module>
    from PIL import Image, ImageFont, ImageDraw
  File "/home/pula/public_html/wttr.in/ve/local/lib/python2.7/site-packages/gevent/builtins.py", line 96, in __import__
    result = _import(*args, **kwargs)
ImportError: No module named PIL

However I have installed the python-pil package!

$ aptitude search python-pil
i A python-pil                                - Python Imaging Library (Pillow fork)    

@chubin
Copy link
Owner

chubin commented May 7, 2019

@j75 Use pip from your virtual environment for that:

ve/bin/pip install Pillow

@j75
Copy link
Author

j75 commented May 7, 2019

A small step forward:

$  ve/bin/python bin/srv.py
Traceback (most recent call last):
  File "bin/srv.py", line 20, in <module>
    import wttr_srv
...
ImportError: No module named pyte.screens

Shouldn't be all these dependencies in requirements.txt?

@chubin
Copy link
Owner

chubin commented May 7, 2019

Actually, they all are mentioned in the README.md file:

If you want to get weather reports as PNG files, you'll also need to install:

    PIL
    pyte (>=0.6)
    necessary fonts

Probably you are right, we should add them to requirements.txt, but they are not there by default because not everybody needs PNG output.

@j75
Copy link
Author

j75 commented May 9, 2019

Neither do I, but how could I specify that? I am following the docs that states that all I have to do is to run ve/bin/python bin/srv.py - is there any option to pass?

Please note that in the documentation the part referring to the configuration is located after the part discussing server start.

@chubin
Copy link
Owner

chubin commented May 9, 2019

@j75 Yes, you are right. We should fix this part. I hope that now is everything configured correctly and almost up and running. Please ping me via email (igor@chub.in), I will mail you the last part that is not committed into this repository, and after that you will have a running 1:1 copy of wttr.in at your local site.

@j75
Copy link
Author

j75 commented May 9, 2019

The last error message I have now is

from globals import GEOLITE, GEOLOCATOR_SERVICE, IP2LCACHE, IP2LOCATION_KEY, NOT_FOUND_LOCATION, \
ImportError: cannot import name IP2LOCATION_KEY

chubin added a commit that referenced this issue May 9, 2019
@chubin
Copy link
Owner

chubin commented May 9, 2019

@j75 It is if you have no IP2location key. This is fixed, please update

@j75
Copy link
Author

j75 commented May 10, 2019

I did, and here's what I have now:

  File "/home/pula/public_html/tmp/wttr.in/ve/local/lib/python2.7/site-packages/maxminddb/__init__.py", line 41, in open_database
    return maxminddb.reader.Reader(database, mode)
  File "/home/pula/public_html/tmp/wttr.in/ve/local/lib/python2.7/site-packages/maxminddb/reader.py", line 52, in __init__
    with open(database, 'rb') as db_file:
IOError: [Errno 2] No such file or directory: '/home/pula/public_html/tmp/wttr.in/data/GeoLite2-City.mmdb'

I have installed (on my Ubuntu system) the geoip-database package and thus I have a file /usr/share/GeoIP/GeoLiteCity.dat that I gave as a value to the WTTR_GEOLITE environment variable; however I noticed that in your README.md you are using a GeoLite2-City.mmdb file, maybe in a different format, how could I get one like that ?

@chubin
Copy link
Owner

chubin commented May 10, 2019

@j75
Copy link
Author

j75 commented May 10, 2019

Well, it spite of defining WTTR_GEOLITE variable, it still spits out

  File "/home/pula/public_html/tmp/wttr.in/ve/local/lib/python2.7/site-packages/maxminddb/reader.py", line 52, in __init__
    with open(database, 'rb') as db_file:
IOError: [Errno 2] No such file or directory: '/home/m.ion/public_html/tmp/wttr.in/data/GeoLite2-City.mmdb'

OK, I moved the file in the data/ folder then I stumble on other errors :

ImportError: No module named dateutil.parser 

Then I performed a ve/bin/pip install python-dateutil and I finnaly reached this error:

  File "/home/m.ion/public_html/tmp/wttr.in/lib/weather_data.py", line 7, in <module>
    from globals import WWO_KEY
ImportError: cannot import name WWO_KEY

@chubin
Copy link
Owner

chubin commented May 10, 2019

Yes, that was my fault. Thank you for reporting it.

  1. python-dateutil was missing in requirements.txt
  2. The WTTR_* environment variables were ignored
  3. if WWO_KEY was not configured, it crashed.

All those problems are fixed now. Now you can use the environment variables,
e.g. you can remove the copy of the Geolite.db from data/ and leave it in the configured place.

Ok, now please:

  1. Update
  2. Create ~/.wwo.key with your WWO key in your home directory, Keep in mind that the key should be configured both for wego and for wttr.in itself (~/.wwo.key)

@j75
Copy link
Author

j75 commented May 13, 2019

Create ~/.wwo.key => what is the format of this file? just the key (12345...) or a JSON?
Because I still have errors:

Installing setuptools, pkg_resources, pip, wheel...done.
Traceback (most recent call last):
  File "bin/srv.py", line 20, in <module>
    import wttr_srv
...
  File "/home/pula/public_html/tmp/wttr.in/lib/wttr_srv.py", line 29, in <module>
    os.makedirs(os.path.dirname(LOG_FILE))
  File "/home/pula/public_html/tmp/wttr.in/ve/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/home/pula/public_html/tmp/wttr.in/ve/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/wttr.in'

@chubin
Copy link
Owner

chubin commented May 13, 2019

Now it is fine; it just tries to create /wttr.in in the root directory, because it is configured as the work directory for wttr.in. Keep in mind that it is code for a dedicated wttr.in server which processes millions queries daily, and it needs a separate data volumes for the data. On the live server it is mounted into /wttr.in.

Now you have two options:

  1. Create /wttr.in and make chown USER /wttr.in for your USER under which wttr.in runs
  2. Specify other directory as the workdir of wttr.in in globals.py

@j75
Copy link
Author

j75 commented May 15, 2019

Yes, the server starts, but performing a GET @ http://127.0.0.1:8002/ results in an internal error (500), the log saying

2019-05-15 16:07:29,693 Exception on / [GET]
Traceback (most recent call last):
  File "/tmp/pula/ve/local/lib/python2.7/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/tmp/pula/ve/local/lib/python2.7/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/tmp/pula/ve/local/lib/python2.7/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/tmp/pula/ve/local/lib/python2.7/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/tmp/pula/ve/local/lib/python2.7/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "bin/srv.py", line 50, in wttr
    return wttr_srv.wttr(location, request)
  File "/tmp/pula/lib/wttr_srv.py", line 200, in wttr
    location_processing(location, ip_addr)
  File "/tmp/pula/lib/location.py", line 225, in location_processing
    query_source_location = get_location(ip_addr)
  File "/tmp/pula/lib/location.py", line 142, in get_location
    city, country = ip2location(ip_addr)
  File "/tmp/pula/lib/location.py", line 111, in ip2location
    if ';' in location:
TypeError: argument of type 'NoneType' is not iterable

@chubin
Copy link
Owner

chubin commented May 15, 2019

@j75 I fixed it, but in your case the IP address can't be geolocated, i.e. you will be sent to Oymyakon

  • try to query it with some city

@j75
Copy link
Author

j75 commented May 20, 2019

Yes, it displays

ERROR: location not found: paris,france
2019/05/20 09:30:56 Get http://127.0.0.1:5001/premium/v1/weather.ashx?key=02fa7c8f8184a27734357dbd2e3cb&q=paris%2Cfrance&format=json&num_of_days=3&tp=3&lang=en: dial tcp 127.0.0.1:5001: connect: connection refused

So, where is this 127.0.0.1:5001/ set and how could it be modified?

@chubin
Copy link
Owner

chubin commented May 23, 2019

Sorry for the delay. It was an extremely busy week, but it is better now.

This time the error message is correct. The problem is that the caching server (that caches all the queries) is not reachable. because you did not start it. Can you please start it first?

$ ve/bin/python ve/bin/proxy.py

As soon as your own server is up and running and functional,
we will update the documentation and fix all the missing parts. Your experience will be invaluable.

Usually people does not install wttr.in on their own, they just use it, but for that rare users that really need to have their own running copy of wttr.in, it is extremely helpful to have up-to-date and correct documentation. Thank you very much for your time and your efforts

@j75
Copy link
Author

j75 commented May 23, 2019

Unfortunately, still doesn't work! 😟
Here's what the proxy displays:

http://api.worldweatheronline.com//premium/v1/weather.ashx?key=xxxxxxx&q=paris%2Cfrance&format=json&num_of_days=3&tp=3&lang=en
[2019-05-23 20:20:50,936] ERROR in app: Exception on /premium/v1/weather.ashx [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 2311, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1834, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1737, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1832, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1818, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "bin/proxy.py", line 193, in proxy
    content = add_translations(response.content, lang)
  File "bin/proxy.py", line 120, in add_translations
    weather_condition = d['data']['current_condition'][0]['weatherDesc'][0]['value']
KeyError: 'current_condition'

My questions are:

  • wouldn't it be possible to add the we-lang.go file to the project?
  • the worldweatheronline URL seems bad (2 double slashes,..),
  • it seems that worldweatheronline does not offer free keys anymore (I used one that I had once, but it is not valid anymore); on the wego project it is advised to use a a forecast.io account

@j75
Copy link
Author

j75 commented May 23, 2019

... however, their configuration file (where the weather provider is chosen) seems to be different from the .wegorc you indicate (yours is a JSON, the other is a simple key=value file), could it work? otherwise, what modifications should be done?

@chubin
Copy link
Owner

chubin commented May 28, 2019

wouldn't it be possible to add the we-lang.go file to the project?

I think that what we will do instead (soon), is that it we will use one own rendering engine,
and so this dependency will become obsolete.

the worldweatheronline URL seems bad (2 double slashes,..),

It does not matter in this case. It should work with double slashes too, even if they look ugly/suspicious

it seems that worldweatheronline does not offer free keys anymore

Please use the URL I've sent you in email.

wegorc configuration

On the server the files looks like:

$ cat ~/.wegorc 
{
        "APIKey": "XXX",
        "City": "London",
        "Numdays": 3,
        "Imperial": false,
        "Lang": "en"
}

But the values are being overridden by command line options, so it actually does not really matter what you have here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants