ushahidi / geograpy

Extract countries, regions and cities from a URL or text
219 stars 133 forks source link

python 3 support #21

Open Erotemic opened 7 years ago

Erotemic commented 7 years ago

the module newspaper won't download because it has changed to newspaper3k. The library itself also seems to have some python3 incompatibilities that could be fixed by running 2to3.

PandaWhoCodes commented 6 years ago

You can try my fix https://github.com/reach2ashish/geograpy Install using python3 -m pip install git+https://github.com/reach2ashish/geograpy.git

EDIT: This only helps to fix the install issues, there are lot of issues with the code which are not compatible with python3 I'll try and cook up a python3 version for this, will take sometime

jaymzcd commented 6 years ago

I made a few fixes to get the example of the BBC article working - not much really, forked from @PandaWhoCodes' fork. I've not tested anything else or Py2 support as yet - just wanted to see what the result would be and get an idea of the amount of work to upgrade it.

https://github.com/jaymzcd/geograpy/commit/56077399b9b67a740c8274c31623c808a74056e2

FWIW I also needed to install the averaged_perceptron_tagger dataset for NTLK also. I added that to the supplied helper.

PandaWhoCodes commented 6 years ago

@jaymzcd cool. Thanks

Michael-E-Rose commented 6 years ago

This package looks exactly like what I need yet I fail to install it on python2 as well as on python3. Python2 fails because newspaper would not let me install it. Python3 fails for the above mentioned problems, but using the provided command fails as well:

michaelerose@panther:~/$ python3 -m pip install git+https://github.com/reach2ashish/geograpy.git
Collecting git+https://github.com/reach2ashish/geograpy.git
  Cloning https://github.com/reach2ashish/geograpy.git to /tmp/pip-gy65h1gy-build
Requirement already satisfied: numpy in /usr/local/lib/python3.5/dist-packages (from geograpy==0.3.7)
Requirement already satisfied: nltk in /usr/local/lib/python3.5/dist-packages (from geograpy==0.3.7)
Requirement already satisfied: newspaper3k in /usr/local/lib/python3.5/dist-packages (from geograpy==0.3.7)
Requirement already satisfied: jellyfish in /usr/local/lib/python3.5/dist-packages (from geograpy==0.3.7)
Requirement already satisfied: pycountry in /usr/local/lib/python3.5/dist-packages (from geograpy==0.3.7)
Requirement already satisfied: six in /usr/local/lib/python3.5/dist-packages (from nltk->geograpy==0.3.7)
Requirement already satisfied: tldextract>=2.0.1 in /usr/local/lib/python3.5/dist-packages (from newspaper3k->geograpy==0.3.7)
Requirement already satisfied: cssselect>=0.9.2 in /usr/local/lib/python3.5/dist-packages (from newspaper3k->geograpy==0.3.7)
Requirement already satisfied: beautifulsoup4>=4.4.1 in /usr/local/lib/python3.5/dist-packages (from newspaper3k->geograpy==0.3.7)
Requirement already satisfied: PyYAML>=3.11 in /usr/local/lib/python3.5/dist-packages (from newspaper3k->geograpy==0.3.7)
Requirement already satisfied: requests>=2.10.0 in /usr/local/lib/python3.5/dist-packages (from newspaper3k->geograpy==0.3.7)
Requirement already satisfied: feedfinder2>=0.0.4 in /usr/local/lib/python3.5/dist-packages (from newspaper3k->geograpy==0.3.7)
Requirement already satisfied: Pillow>=3.3.0 in /usr/local/lib/python3.5/dist-packages (from newspaper3k->geograpy==0.3.7)
Requirement already satisfied: lxml>=3.6.0 in /usr/local/lib/python3.5/dist-packages (from newspaper3k->geograpy==0.3.7)
Requirement already satisfied: python-dateutil>=2.5.3 in /usr/local/lib/python3.5/dist-packages (from newspaper3k->geograpy==0.3.7)
Requirement already satisfied: feedparser>=5.2.1 in /usr/local/lib/python3.5/dist-packages (from newspaper3k->geograpy==0.3.7)
Requirement already satisfied: jieba3k>=0.35.1 in /usr/local/lib/python3.5/dist-packages (from newspaper3k->geograpy==0.3.7)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from tldextract>=2.0.1->newspaper3k->geograpy==0.3.7)
Requirement already satisfied: idna in /usr/local/lib/python3.5/dist-packages (from tldextract>=2.0.1->newspaper3k->geograpy==0.3.7)
Requirement already satisfied: requests-file>=1.4 in /usr/local/lib/python3.5/dist-packages (from tldextract>=2.0.1->newspaper3k->geograpy==0.3.7)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.5/dist-packages (from requests>=2.10.0->newspaper3k->geograpy==0.3.7)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.5/dist-packages (from requests>=2.10.0->newspaper3k->geograpy==0.3.7)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in /usr/local/lib/python3.5/dist-packages (from requests>=2.10.0->newspaper3k->geograpy==0.3.7)
Installing collected packages: geograpy
  Running setup.py install for geograpy ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-gy65h1gy-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-eqzb7x5v-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib
    creating build/lib/geograpy
    copying geograpy/utils.py -> build/lib/geograpy
    copying geograpy/__init__.py -> build/lib/geograpy
    copying geograpy/extraction.py -> build/lib/geograpy
    copying geograpy/places.py -> build/lib/geograpy
    creating build/lib/geograpy/data
    copying geograpy/data/GeoLite2-City-Locations.csv -> build/lib/geograpy/data
    copying geograpy/data/ISO3166ErrorDictionary.csv -> build/lib/geograpy/data
    running build_scripts
    creating build/scripts-3.5
    copying geograpy/bin/geograpy-nltk -> build/scripts-3.5
    changing mode of build/scripts-3.5/geograpy-nltk from 664 to 775
    running install_lib
    creating /usr/local/lib/python3.5/dist-packages/geograpy
    error: could not create '/usr/local/lib/python3.5/dist-packages/geograpy': Permission denied

    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-gy65h1gy-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-eqzb7x5v-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-gy65h1gy-build/
jamiebull1 commented 6 years ago

@Michael-E-Rose Try sudo chown -R $USER /usr/local/lib/python3.5 to make sure your user has permission to write to the Python3 folder.

Michael-E-Rose commented 6 years ago

Seemed to work @jamiebull1 ! Thank you