google / transitfeed

A Python library for reading, validating, and writing transit schedule information in the GTFS format.
https://github.com/google/transitfeed/wiki
Apache License 2.0
679 stars 254 forks source link

Syntax error while installing Python3 #511

Open AkhilJPatil opened 4 years ago

AkhilJPatil commented 4 years ago

Not sure if transitfeed is ready for python3! Already went through #493, #412 and response by pecalleja 4 months ago.

Tried installing the transitfeed module on windows 10, Python version: 3.5.2 and ubuntu 18.04.3, Python version: 3.6.9

Getting below syntax error. Is there an error free alternate file availble at some other path or should just remove the syntax locally and try to install it.

#############################WIN10###############################

pip install transitfeed --user --no-index --find-links C:/Users//Downloads/transitfeed-1.2.16.tar.gz WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip. Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue. To avoid this problem you can invoke Python with '-m pip' instead of running pip directly. Looking in links: c:/Users//Downloads/transitfeed-1.2.16.tar.gz Processing c:\users\\downloads\transitfeed-1.2.16.tar.gz ERROR: Command errored out with exit status 1: command: 'c:\program files\python35\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\\AppData\Local\Temp\pip-install-z4hqaij0\transitfeed\setup.py'"'"'; file='"'"'C:\Users\\AppData\Local\Temp\pip-install-z4hqaij0\transitfeed\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\\AppData\Local\Temp\pip-install-z4hqaij0\transitfeed\pip-egg-info' cwd: C:\Users\\AppData\Local\Temp\pip-install-z4hqaij0\transitfeed\ Complete output (6 lines): Traceback (most recent call last): File "", line 1, in File "C:\Users\\AppData\Local\Temp\pip-install-z4hqaij0\transitfeed\setup.py", line 34 except ImportError, e: ^ SyntaxError: invalid syntax ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

#############################UBUNTU###############################

~$ pip install transitfeed Collecting transitfeed Downloading https://files.pythonhosted.org/packages/56/63/b129a3addfcb4b71033875d62ab4106b96498c2fb56dfdbf05542274b2cf/transitfeed-1.2.16.tar.gz (359kB) 100% |████████████████████████████████| 368kB 1.1MB/s Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 1, in File "/tmp/pip-build-t_16sefl/transitfeed/setup.py", line 34 except ImportError, e: ^ SyntaxError: invalid syntax

----------------------------------------

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

Please suggest. Thanks!

pecalleja commented 4 years ago

there is a fork with python3 support but you need to manually install from sources.

follow these steps ** : 1 - clone the python3 fork and change to python3 branch

git clone https://github.com/pecalleja/transitfeed.git

cd transitfeed

git checkout python3

2 - create a virtual environment and activate it

virtualenv -p python3 venv

source venv/bin/activate

3 - Install the requirements

pip install -r requirements.txt

4 - install the package

python setup.py install

5 - run all test

nosetests -x -vv tests

(** no tested in windows)

On Tue, Mar 17, 2020 at 4:25 PM Nathan Schepers notifications@github.com wrote:

I was considering porting the whole thing to python3, but also wondered whether there was a python3 version somewhere else already. If there's not, I'll do the work, but probably need a little guidance from the maintainers wrt what they'd like in a PR.

Please advise. Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/google/transitfeed/issues/511#issuecomment-600329791, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA643IYS2UNXVHH3DKDRSQ3RH72F5ANCNFSM4LE7OYDQ .

campbellhealy commented 4 years ago

In the util.py file change the import urllib2 to import urllib and that will solve this issue and install on the latest version of Python