python - ImportError: cannot import name get_sorted_tuples -


there 2 files in same directory.

the first file parser.py:

from collections import ordereddict import csv import json import requests import time collections import defaultdict  def load_matrices():     # code... def get_sorted_tuples(matrix, country, code_to_name, size=20):     # code... 

the second b.py:

from collections import ordereddict import json geojsontosvg import lolatoxy parser import get_sorted_tuples, load_matrices import math 

when run b.py, error:

from parser import get_sorted_tuples, load_matrices importerror: cannot import name get_sorted_tuples 

what's wrong code?

the problem here python has module named parser in standard library, , that's you're trying import from. have 2 options:

  • rename parser.py else.
  • if both files inside package, relative import in b.py:
from .parser import get_sorted_tuples, load_matrices 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -