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

SyntaxError: Non-ASCII character '\xc3' in file ./ia on line 3 #420

Closed
ghost opened this issue Jul 22, 2021 · 10 comments
Closed

SyntaxError: Non-ASCII character '\xc3' in file ./ia on line 3 #420

ghost opened this issue Jul 22, 2021 · 10 comments

Comments

@ghost
Copy link

ghost commented Jul 22, 2021

Just downloaded the ia binary linked at https://archive.org/services/docs/api/internetarchive/installation.html#binaries

I did chmod +x but anytime I run, with or without arguments, it I get the following:

% ./ia help
  File "./ia", line 2
SyntaxError: Non-ASCII character '\xc3' in file ./ia on line 3, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Python 2.7.16
macOS 11.4 (Big Sur) M1 processor.

Edit (more info): Shell % echo $LANG
en_IE.UTF-8
Same error explained on stackoverflow: https://stackoverflow.com/questions/26899235/python-nltk-syntaxerror-non-ascii-character-xc3-in-file-sentiment-analysis

@jjjake
Copy link
Owner

jjjake commented Jul 26, 2021

Interesting, I have not seen this issue before and am unable to replicate it. I'm not sure what's going on here, but I'll see what I can do. Thanks for the report!

@ghost
Copy link
Author

ghost commented Aug 8, 2021

Thanks a lot :) And if there's a workaround for M1 in the mean time, I'm all ears! https://archive.org/details/amiga-ireland

@ghost
Copy link
Author

ghost commented Sep 18, 2021

Update: not sure if this is due to brew upgrades, but there's been some change. This is what I get now for output for "ia help". Different results for python2 and python3.

% ia help
Traceback (most recent call last):
 File "/usr/local/bin/ia", line 11, in <module>
   load_entry_point('internetarchive==2.0.3', 'console_scripts', 'ia')()
 File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 489, in load_entry_point
   return get_distribution(dist).load_entry_point(group, name)
 File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2843, in load_entry_point
   return ep.load()
 File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2434, in load
   return self.resolve()
 File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2440, in resolve
   module = __import__(self.module_name, fromlist=['__name__'], level=0)
 File "/Library/Python/2.7/site-packages/internetarchive-2.0.3-py2.7.egg/internetarchive/cli/__init__.py", line 27, in <module>
   from internetarchive.cli import (ia, ia_configure, ia_delete, ia_download,
 File "/Library/Python/2.7/site-packages/internetarchive-2.0.3-py2.7.egg/internetarchive/cli/ia.py", line 67, in <module>
   from schema import Schema, Or, SchemaError
 File "/Library/Python/2.7/site-packages/schema-0.7.4-py2.7.egg/schema.py", line 10, in <module>
   from contextlib2 import ExitStack
 File "/Library/Python/2.7/site-packages/contextlib2-21.6.0-py2.7.egg/contextlib2/__init__.py", line 56
   async def __aenter__(self):
           ^
SyntaxError: invalid syntax

iMac ~ % 
iMac ~ % 
iMac ~ % 

iMac ~ % python3 $(which ia help)
Traceback (most recent call last):
 File "/usr/local/bin/ia", line 6, in <module>
   from pkg_resources import load_entry_point
 File "/opt/homebrew/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3243, in <module>
   def _initialize_master_working_set():
 File "/opt/homebrew/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3226, in _call_aside
   f(*args, **kwargs)
 File "/opt/homebrew/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3255, in _initialize_master_working_set
   working_set = WorkingSet._build_master()
 File "/opt/homebrew/lib/python3.9/site-packages/pkg_resources/__init__.py", line 568, in _build_master
   ws.require(__requires__)
 File "/opt/homebrew/lib/python3.9/site-packages/pkg_resources/__init__.py", line 886, in require
   needed = self.resolve(parse_requirements(requirements))
 File "/opt/homebrew/lib/python3.9/site-packages/pkg_resources/__init__.py", line 772, in resolve
   raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'internetarchive==2.0.3' distribution was not found and is required by the application
iMac ~ % 

@JustAnotherArchivist
Copy link
Contributor

The first traceback shows that contextlib2 no longer supports Python 2 (which has been EOL for nearly two years now). It was indeed dropped recently.

The second traceback is what I'd expect with any invocation that doesn't call the binary. The binary already contains Python and all package dependencies; because the latter aren't actually installed on the system, your system python3 can't find them.

@ghost
Copy link
Author

ghost commented Sep 19, 2021

The binary already contains Python and all package dependencies; because the latter aren't actually installed on the system, your system python3 can't find them.

I see. The docs at the link in my first post say that the "requirement for using the binaries is that you have Python installed on a Unix-like operating system."

Workaround: Installing internetarchive with brew on the command line has given me a functioning binary.

@JustAnotherArchivist
Copy link
Contributor

My mistake, I was thinking of something else there. Python itself actually isn't packaged and does need to be installed. python3 ./ia help works fine for me though with Python 3.9.7. (Straight ./ia help doesn't because the hashbang references a python executable and I uninstalled Python 2 a long time ago.)

@ghost
Copy link
Author

ghost commented Sep 19, 2021

I'm assuming there must be a difference between the direct binary available at the link in my first post and what is provided by home-brew. But I'm happy to have a working setup again. For anyone else having the issues in my 1st or 3rd post, just get it from a repo such as brew/apt and not from https://archive.org/services/docs/api/internetarchive/installation.html#binaries

Edit: @jjjake posted advice below. Better to heed that.

@JustAnotherArchivist
Copy link
Contributor

Yes, the brew installation is completely unrelated to the ia-pex binary. As far as I can see from the formula, it seems to simply install Python 3.9 and the ia Python package with its dependencies directly (in an isolated manner).

@jjjake
Copy link
Owner

jjjake commented Sep 21, 2021

For the record, I would not suggest using brew to install internetarchive. I would suggest using one of the methods listed here.

ia works fine for me on Python 2 when installed with pip, easy_install, or using the binary. I'm unable to replicate your issue, but I'll keep poking around. Thanks for the report!

@JustAnotherArchivist
Copy link
Contributor

@jjjake With Python 2 support dropped, I'm pretty sure this is no longer relevant and can be closed.

@jjjake jjjake closed this as completed Feb 11, 2022
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