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

Name 'unicode' is not defined in Python 3 #49

Open
waleedka opened this issue May 13, 2017 · 7 comments
Open

Name 'unicode' is not defined in Python 3 #49

waleedka opened this issue May 13, 2017 · 7 comments

Comments

@waleedka
Copy link

I'm getting this error when I call loadRes() with Python 3.5. Python 3 replaced unicode with str.

coco_results = coco_val.loadRes(results)

This is the stack trace:

/usr/local/lib/python3.5/dist-packages/pycocotools/coco.py in loadRes(self, resFile)
    301         print('Loading and preparing results...')
    302         tic = time.time()
--> 303         if type(resFile) == str or type(resFile) == unicode:
    304             anns = json.load(open(resFile))
    305         elif type(resFile) == np.ndarray:

NameError: name 'unicode' is not defined
@RubensZimbres
Copy link

Alter line 308 of coco.py at pycocotools library directory, from:
if type(resFile) == str or type(resFile) == unicode:
to:
if type(resFile) == str or type(resFile) == bytes:
Works perfectly for Python 3

@waleedka
Copy link
Author

Thanks, but I already submitted a pull request to fix this. Looking at the date, it's been a year now and the PR has not been merged. I ended up forking the repo and I'm using my forked version in all future work.

@Gvanderl
Copy link

Gvanderl commented Aug 9, 2018

Just ran into this problem, pls fix

@martin-gorner
Copy link

same here. Pycocotools does not seem to be Python 3 compatible.

@luxedo
Copy link

luxedo commented May 3, 2019

In a quick search I found that there's at least 5 PRs that should solve this issue.

@tgandor
Copy link

tgandor commented Feb 15, 2020

This is fixed on master, but not on PyPI (e.g. detectron2 sugests to install like:
pip install -U 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI').
Hey, Authors! How about:

  • adding a versioning scheme, like pycocotools.__version__, e.g. '2.0.1'
  • publishing the new version on PyPI
    ?

@almajeas
Copy link

Is there a new direction by the authors to refer python3 compatibility issues to a different source? or should we just wait and hope the pullrequesets go through eventually?

fracpete added a commit to waikato-datamining/tensorflow that referenced this issue Jun 2, 2020
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

7 participants