[{"data":1,"prerenderedAt":1405},["ShallowReactive",2],{"doc-\u002Ferrors\u002Fimporterror-cannot-import-name-fix":3},{"id":4,"title":5,"body":6,"description":1398,"extension":1399,"meta":1400,"navigation":95,"path":1401,"seo":1402,"stem":1403,"__hash__":1404},"content\u002Ferrors\u002Fimporterror-cannot-import-name-fix.md","ImportError: cannot import name (Fix)",{"type":7,"value":8,"toc":1370},"minimark",[9,13,25,28,47,50,55,159,162,166,172,180,183,200,210,219,223,226,240,243,285,288,303,306,343,346,355,358,369,373,376,437,449,453,456,544,549,611,613,629,639,643,646,649,656,704,710,751,754,775,778,813,816,827,834,838,841,845,848,859,863,866,869,873,901,904,907,911,936,939,943,946,965,968,974,978,981,984,988,991,1010,1013,1055,1058,1073,1080,1082,1114,1116,1125,1129,1132,1185,1188,1215,1218,1250,1254,1258,1264,1269,1273,1276,1280,1283,1296,1300,1307,1309,1334,1338,1366],[10,11,5],"h1",{"id":12},"importerror-cannot-import-name-fix",[14,15,16,17,24],"p",{},"If you see the Python error ",[18,19,20],"strong",{},[21,22,23],"code",{},"ImportError: cannot import name ...",", Python was able to find the module, but it could not find the specific function, class, or variable you asked for.",[14,26,27],{},"This usually happens because:",[29,30,31,35,38,41,44],"ul",{},[32,33,34],"li",{},"the name is spelled wrong",[32,36,37],{},"you imported from the wrong module",[32,39,40],{},"the name is not available at the top level",[32,42,43],{},"there is a circular import",[32,45,46],{},"a local file is conflicting with a real module",[14,48,49],{},"This guide shows how to find the cause and fix it.",[51,52,54],"h2",{"id":53},"quick-fix","Quick fix",[56,57,62],"pre",{"className":58,"code":59,"language":60,"meta":61,"style":61},"language-python shiki shiki-themes material-theme-lighter github-light github-dark","# Check that the name really exists in the module\nfrom mymodule import my_function\n\n# Alternative: import the module first, then inspect it\nimport mymodule\nprint(dir(mymodule))\n\n# Then access the name with dot notation if it exists\nmymodule.my_function()\n","python","",[21,63,64,73,90,97,103,111,134,139,145],{"__ignoreMap":61},[65,66,69],"span",{"class":67,"line":68},"line",1,[65,70,72],{"class":71},"sutJx","# Check that the name really exists in the module\n",[65,74,76,80,84,87],{"class":67,"line":75},2,[65,77,79],{"class":78},"sVHd0","from",[65,81,83],{"class":82},"su5hD"," mymodule ",[65,85,86],{"class":78},"import",[65,88,89],{"class":82}," my_function\n",[65,91,93],{"class":67,"line":92},3,[65,94,96],{"emptyLinePlaceholder":95},true,"\n",[65,98,100],{"class":67,"line":99},4,[65,101,102],{"class":71},"# Alternative: import the module first, then inspect it\n",[65,104,106,108],{"class":67,"line":105},5,[65,107,86],{"class":78},[65,109,110],{"class":82}," mymodule\n",[65,112,114,118,122,125,127,131],{"class":67,"line":113},6,[65,115,117],{"class":116},"sptTA","print",[65,119,121],{"class":120},"sP7_E","(",[65,123,124],{"class":116},"dir",[65,126,121],{"class":120},[65,128,130],{"class":129},"slqww","mymodule",[65,132,133],{"class":120},"))\n",[65,135,137],{"class":67,"line":136},7,[65,138,96],{"emptyLinePlaceholder":95},[65,140,142],{"class":67,"line":141},8,[65,143,144],{"class":71},"# Then access the name with dot notation if it exists\n",[65,146,148,150,153,156],{"class":67,"line":147},9,[65,149,130],{"class":82},[65,151,152],{"class":120},".",[65,154,155],{"class":129},"my_function",[65,157,158],{"class":120},"()\n",[14,160,161],{},"This error usually means the name does not exist, is spelled wrong, is defined in the wrong file, or there is a circular import.",[51,163,165],{"id":164},"what-this-error-means","What this error means",[14,167,168,171],{},[21,169,170],{},"ImportError: cannot import name"," means:",[29,173,174,177],{},[32,175,176],{},"Python found the module",[32,178,179],{},"but Python could not find the specific name inside that module",[14,181,182],{},"For example, this can fail:",[56,184,186],{"className":58,"code":185,"language":60,"meta":61,"style":61},"from math import square\n",[21,187,188],{"__ignoreMap":61},[65,189,190,192,195,197],{"class":67,"line":68},[65,191,79],{"class":78},[65,193,194],{"class":82}," math ",[65,196,86],{"class":78},[65,198,199],{"class":82}," square\n",[14,201,202,203,206,207,152],{},"because the ",[21,204,205],{},"math"," module exists, but it does not provide a name called ",[21,208,209],{},"square",[14,211,212,213,218],{},"This is different from ",[214,215,217],"a",{"href":216},"\u002Ferrors\u002Fmodulenotfounderror-no-module-named-x-fix\u002F","ModuleNotFoundError: no module named x",", where Python cannot find the module at all.",[51,220,222],{"id":221},"common-example-that-causes-the-error","Common example that causes the error",[14,224,225],{},"A simple example:",[56,227,228],{"className":58,"code":185,"language":60,"meta":61,"style":61},[21,229,230],{"__ignoreMap":61},[65,231,232,234,236,238],{"class":67,"line":68},[65,233,79],{"class":78},[65,235,194],{"class":82},[65,237,86],{"class":78},[65,239,199],{"class":82},[14,241,242],{},"Expected result:",[56,244,246],{"className":58,"code":245,"language":60,"meta":61,"style":61},"ImportError: cannot import name 'square' from 'math'\n",[21,247,248],{"__ignoreMap":61},[65,249,250,254,257,260,262,265,269,272,274,277,280,282],{"class":67,"line":68},[65,251,253],{"class":252},"sZMiF","ImportError",[65,255,256],{"class":120},":",[65,258,259],{"class":82}," cannot ",[65,261,86],{"class":78},[65,263,264],{"class":82}," name ",[65,266,268],{"class":267},"sjJ54","'",[65,270,209],{"class":271},"s_sjI",[65,273,268],{"class":267},[65,275,276],{"class":78}," from",[65,278,279],{"class":267}," '",[65,281,205],{"class":271},[65,283,284],{"class":267},"'\n",[14,286,287],{},"Why this fails:",[29,289,290,295],{},[32,291,292,294],{},[21,293,205],{}," is a real module",[32,296,297,298,300,301],{},"but ",[21,299,209],{}," is not a function in ",[21,302,205],{},[14,304,305],{},"A correct version would be:",[56,307,309],{"className":58,"code":308,"language":60,"meta":61,"style":61},"import math\n\nprint(math.sqrt(16))\n",[21,310,311,318,322],{"__ignoreMap":61},[65,312,313,315],{"class":67,"line":68},[65,314,86],{"class":78},[65,316,317],{"class":82}," math\n",[65,319,320],{"class":67,"line":75},[65,321,96],{"emptyLinePlaceholder":95},[65,323,324,326,328,330,332,335,337,341],{"class":67,"line":92},[65,325,117],{"class":116},[65,327,121],{"class":120},[65,329,205],{"class":129},[65,331,152],{"class":120},[65,333,334],{"class":129},"sqrt",[65,336,121],{"class":120},[65,338,340],{"class":339},"srdBf","16",[65,342,133],{"class":120},[14,344,345],{},"Output:",[56,347,349],{"className":58,"code":348,"language":60,"meta":61,"style":61},"4.0\n",[21,350,351],{"__ignoreMap":61},[65,352,353],{"class":67,"line":68},[65,354,348],{"class":339},[14,356,357],{},"Other common cases:",[29,359,360,363,366],{},[32,361,362],{},"you try to import a function that was renamed or deleted",[32,364,365],{},"you import from the wrong file with a similar name",[32,367,368],{},"you copy example code written for a different package version",[51,370,372],{"id":371},"why-it-happens","Why it happens",[14,374,375],{},"Here are the most common reasons:",[29,377,378,393,401,413,421,429],{},[32,379,380,383,386,387,390,391,152],{},[18,381,382],{},"Misspelled name",[384,385],"br",{},"\nYou wrote ",[21,388,389],{},"my_fuction"," instead of ",[21,392,155],{},[32,394,395,398,400],{},[18,396,397],{},"Wrong module",[384,399],{},"\nThe name exists, but in a different module.",[32,402,403,406,408,409,412],{},[18,404,405],{},"Name is not at the top level",[384,407],{},"\nThe value may only be created inside a function, loop, or ",[21,410,411],{},"if"," block.",[32,414,415,418,420],{},[18,416,417],{},"Circular import",[384,419],{},"\nTwo files import from each other before loading is complete.",[32,422,423,426,428],{},[18,424,425],{},"Local file conflict",[384,427],{},"\nA file in your project has the same name as a standard library module or installed package.",[32,430,431,434,436],{},[18,432,433],{},"Package version changed",[384,435],{},"\nThe example you copied may use an older or newer API.",[14,438,439,440,444,445,152],{},"If you are not comfortable with how imports work, see ",[214,441,443],{"href":442},"\u002Flearn\u002Fhow-import-works-in-python\u002F","how import works in Python"," and ",[214,446,448],{"href":447},"\u002Fhow-to\u002Fhow-to-import-a-module-in-python\u002F","how to import a module in Python",[51,450,452],{"id":451},"how-to-fix-it","How to fix it",[14,454,455],{},"Try these fixes in order:",[457,458,459,469,479,492,502,524,534],"ol",{},[32,460,461,464],{},[18,462,463],{},"Check the spelling",[29,465,466],{},[32,467,468],{},"Compare the imported name with the real name in the module.",[32,470,471,474],{},[18,472,473],{},"Open the module",[29,475,476],{},[32,477,478],{},"Confirm the function, class, or variable actually exists.",[32,480,481,484],{},[18,482,483],{},"Import the module first",[29,485,486],{},[32,487,488,489,152],{},"Then inspect it with ",[21,490,491],{},"dir()",[32,493,494,497],{},[18,495,496],{},"Make sure the module is the correct one",[29,498,499],{},[32,500,501],{},"You may be importing a different file than you think.",[32,503,504,507],{},[18,505,506],{},"Rename conflicting local files",[29,508,509],{},[32,510,511,512,515,516,519,520,523],{},"Files like ",[21,513,514],{},"random.py",", ",[21,517,518],{},"json.py",", or ",[21,521,522],{},"os.py"," often cause problems.",[32,525,526,529],{},[18,527,528],{},"Fix circular imports",[29,530,531],{},[32,532,533],{},"Move shared code into a third file, or move imports inside functions when appropriate.",[32,535,536,539],{},[18,537,538],{},"Check package documentation",[29,540,541],{},[32,542,543],{},"The name may have moved or been removed in your installed version.",[14,545,546,547,256],{},"Example using ",[21,548,491],{},[56,550,552],{"className":58,"code":551,"language":60,"meta":61,"style":61},"import math\n\nprint(\"square\" in dir(math))\nprint(\"sqrt\" in dir(math))\n",[21,553,554,560,564,589],{"__ignoreMap":61},[65,555,556,558],{"class":67,"line":68},[65,557,86],{"class":78},[65,559,317],{"class":82},[65,561,562],{"class":67,"line":75},[65,563,96],{"emptyLinePlaceholder":95},[65,565,566,568,570,573,575,577,580,583,585,587],{"class":67,"line":92},[65,567,117],{"class":116},[65,569,121],{"class":120},[65,571,572],{"class":267},"\"",[65,574,209],{"class":271},[65,576,572],{"class":267},[65,578,579],{"class":78}," in",[65,581,582],{"class":116}," dir",[65,584,121],{"class":120},[65,586,205],{"class":129},[65,588,133],{"class":120},[65,590,591,593,595,597,599,601,603,605,607,609],{"class":67,"line":99},[65,592,117],{"class":116},[65,594,121],{"class":120},[65,596,572],{"class":267},[65,598,334],{"class":271},[65,600,572],{"class":267},[65,602,579],{"class":78},[65,604,582],{"class":116},[65,606,121],{"class":120},[65,608,205],{"class":129},[65,610,133],{"class":120},[14,612,345],{},[56,614,616],{"className":58,"code":615,"language":60,"meta":61,"style":61},"False\nTrue\n",[21,617,618,624],{"__ignoreMap":61},[65,619,620],{"class":67,"line":68},[65,621,623],{"class":622},"s39Yj","False\n",[65,625,626],{"class":67,"line":75},[65,627,628],{"class":622},"True\n",[14,630,631,632,152],{},"You can learn more about this with the ",[214,633,635,636,638],{"href":634},"\u002Freference\u002Fpython-dir-function-explained\u002F","Python ",[21,637,491],{}," function explained",[51,640,642],{"id":641},"circular-import-case","Circular import case",[14,644,645],{},"A circular import happens when two files depend on each other while Python is still loading them.",[14,647,648],{},"Example:",[650,651,653],"h3",{"id":652},"apy",[21,654,655],{},"a.py",[56,657,659],{"className":58,"code":658,"language":60,"meta":61,"style":61},"from b import greet_b\n\ndef greet_a():\n    return \"Hello from A\"\n",[21,660,661,673,677,690],{"__ignoreMap":61},[65,662,663,665,668,670],{"class":67,"line":68},[65,664,79],{"class":78},[65,666,667],{"class":82}," b ",[65,669,86],{"class":78},[65,671,672],{"class":82}," greet_b\n",[65,674,675],{"class":67,"line":75},[65,676,96],{"emptyLinePlaceholder":95},[65,678,679,683,687],{"class":67,"line":92},[65,680,682],{"class":681},"sbsja","def",[65,684,686],{"class":685},"sGLFI"," greet_a",[65,688,689],{"class":120},"():\n",[65,691,692,695,698,701],{"class":67,"line":99},[65,693,694],{"class":78},"    return",[65,696,697],{"class":267}," \"",[65,699,700],{"class":271},"Hello from A",[65,702,703],{"class":267},"\"\n",[650,705,707],{"id":706},"bpy",[21,708,709],{},"b.py",[56,711,713],{"className":58,"code":712,"language":60,"meta":61,"style":61},"from a import greet_a\n\ndef greet_b():\n    return \"Hello from B\"\n",[21,714,715,727,731,740],{"__ignoreMap":61},[65,716,717,719,722,724],{"class":67,"line":68},[65,718,79],{"class":78},[65,720,721],{"class":82}," a ",[65,723,86],{"class":78},[65,725,726],{"class":82}," greet_a\n",[65,728,729],{"class":67,"line":75},[65,730,96],{"emptyLinePlaceholder":95},[65,732,733,735,738],{"class":67,"line":92},[65,734,682],{"class":681},[65,736,737],{"class":685}," greet_b",[65,739,689],{"class":120},[65,741,742,744,746,749],{"class":67,"line":99},[65,743,694],{"class":78},[65,745,697],{"class":267},[65,747,748],{"class":271},"Hello from B",[65,750,703],{"class":267},[14,752,753],{},"This setup can fail because:",[29,755,756,763,770],{},[32,757,758,760,761],{},[21,759,655],{}," starts importing ",[21,762,709],{},[32,764,765,767,768],{},[21,766,709],{}," then tries to import from ",[21,769,655],{},[32,771,297,772,774],{},[21,773,655],{}," has not finished loading yet",[14,776,777],{},"A common error looks like this:",[56,779,781],{"className":58,"code":780,"language":60,"meta":61,"style":61},"ImportError: cannot import name 'greet_a' from partially initialized module 'a'\n",[21,782,783],{"__ignoreMap":61},[65,784,785,787,789,791,793,795,797,800,802,804,807,809,811],{"class":67,"line":68},[65,786,253],{"class":252},[65,788,256],{"class":120},[65,790,259],{"class":82},[65,792,86],{"class":78},[65,794,264],{"class":82},[65,796,268],{"class":267},[65,798,799],{"class":271},"greet_a",[65,801,268],{"class":267},[65,803,276],{"class":78},[65,805,806],{"class":82}," partially initialized module ",[65,808,268],{"class":267},[65,810,214],{"class":271},[65,812,284],{"class":267},[14,814,815],{},"Common fixes:",[29,817,818,821,824],{},[32,819,820],{},"move the import inside a function",[32,822,823],{},"move shared code into a third file",[32,825,826],{},"restructure the files so only one depends on the other",[14,828,829,830,833],{},"For example, moving shared code to ",[21,831,832],{},"common.py"," often fixes the problem.",[51,835,837],{"id":836},"how-to-debug-step-by-step","How to debug step by step",[14,839,840],{},"Use this process when you are stuck.",[650,842,844],{"id":843},"_1-read-the-full-traceback","1. Read the full traceback",[14,846,847],{},"Look for:",[29,849,850,853,856],{},[32,851,852],{},"the module name",[32,854,855],{},"the imported name",[32,857,858],{},"the file path Python is using",[650,860,862],{"id":861},"_2-open-the-target-module","2. Open the target module",[14,864,865],{},"Search for the missing name.",[14,867,868],{},"Make sure it is really defined, and spelled the same way.",[650,870,872],{"id":871},"_3-check-which-file-python-imported","3. Check which file Python imported",[56,874,876],{"className":58,"code":875,"language":60,"meta":61,"style":61},"import mymodule\nprint(mymodule.__file__)\n",[21,877,878,884],{"__ignoreMap":61},[65,879,880,882],{"class":67,"line":68},[65,881,86],{"class":78},[65,883,110],{"class":82},[65,885,886,888,890,892,894,898],{"class":67,"line":75},[65,887,117],{"class":116},[65,889,121],{"class":120},[65,891,130],{"class":129},[65,893,152],{"class":120},[65,895,897],{"class":896},"s_hVV","__file__",[65,899,900],{"class":120},")\n",[14,902,903],{},"This shows the actual file path Python loaded.",[14,905,906],{},"That helps you catch problems where you are importing the wrong file.",[650,908,910],{"id":909},"_4-list-the-names-in-the-module","4. List the names in the module",[56,912,914],{"className":58,"code":913,"language":60,"meta":61,"style":61},"import mymodule\nprint(dir(mymodule))\n",[21,915,916,922],{"__ignoreMap":61},[65,917,918,920],{"class":67,"line":68},[65,919,86],{"class":78},[65,921,110],{"class":82},[65,923,924,926,928,930,932,934],{"class":67,"line":75},[65,925,117],{"class":116},[65,927,121],{"class":120},[65,929,124],{"class":116},[65,931,121],{"class":120},[65,933,130],{"class":129},[65,935,133],{"class":120},[14,937,938],{},"If your name is missing from the list, Python cannot import it from that module.",[650,940,942],{"id":941},"_5-look-for-local-filename-conflicts","5. Look for local filename conflicts",[14,944,945],{},"Check your project folder for files like:",[29,947,948,952,956,960],{},[32,949,950],{},[21,951,514],{},[32,953,954],{},[21,955,518],{},[32,957,958],{},[21,959,522],{},[32,961,962],{},[21,963,964],{},"math.py",[14,966,967],{},"These can shadow the real modules.",[14,969,970,971,973],{},"For example, if you create a file named ",[21,972,964],{},", then this import may not use the real standard library module.",[650,975,977],{"id":976},"_6-check-for-circular-imports","6. Check for circular imports",[14,979,980],{},"Look for two files importing each other.",[14,982,983],{},"If file A imports from file B, and file B imports from file A, that is a strong sign of a circular import.",[51,985,987],{"id":986},"common-causes","Common causes",[14,989,990],{},"These are the most common causes of this error:",[29,992,993,996,999,1001,1004,1007],{},[32,994,995],{},"Misspelled imported name",[32,997,998],{},"Wrong module path",[32,1000,417],{},[32,1002,1003],{},"Local file name conflict",[32,1005,1006],{},"Outdated example code for a newer package version",[32,1008,1009],{},"Trying to import a name that is created only inside a function or condition",[14,1011,1012],{},"Here is an example of a name that cannot be imported because it is not defined at the top level:",[56,1014,1016],{"className":58,"code":1015,"language":60,"meta":61,"style":61},"# mymodule.py\n\ndef make_value():\n    hidden_value = 10\n    return hidden_value\n",[21,1017,1018,1023,1027,1036,1048],{"__ignoreMap":61},[65,1019,1020],{"class":67,"line":68},[65,1021,1022],{"class":71},"# mymodule.py\n",[65,1024,1025],{"class":67,"line":75},[65,1026,96],{"emptyLinePlaceholder":95},[65,1028,1029,1031,1034],{"class":67,"line":92},[65,1030,682],{"class":681},[65,1032,1033],{"class":685}," make_value",[65,1035,689],{"class":120},[65,1037,1038,1041,1045],{"class":67,"line":99},[65,1039,1040],{"class":82},"    hidden_value ",[65,1042,1044],{"class":1043},"smGrS","=",[65,1046,1047],{"class":339}," 10\n",[65,1049,1050,1052],{"class":67,"line":105},[65,1051,694],{"class":78},[65,1053,1054],{"class":82}," hidden_value\n",[14,1056,1057],{},"This will fail:",[56,1059,1061],{"className":58,"code":1060,"language":60,"meta":61,"style":61},"from mymodule import hidden_value\n",[21,1062,1063],{"__ignoreMap":61},[65,1064,1065,1067,1069,1071],{"class":67,"line":68},[65,1066,79],{"class":78},[65,1068,83],{"class":82},[65,1070,86],{"class":78},[65,1072,1054],{"class":82},[14,1074,1075,1076,1079],{},"because ",[21,1077,1078],{},"hidden_value"," only exists inside the function.",[14,1081,305],{},[56,1083,1085],{"className":58,"code":1084,"language":60,"meta":61,"style":61},"from mymodule import make_value\n\nprint(make_value())\n",[21,1086,1087,1098,1102],{"__ignoreMap":61},[65,1088,1089,1091,1093,1095],{"class":67,"line":68},[65,1090,79],{"class":78},[65,1092,83],{"class":82},[65,1094,86],{"class":78},[65,1096,1097],{"class":82}," make_value\n",[65,1099,1100],{"class":67,"line":75},[65,1101,96],{"emptyLinePlaceholder":95},[65,1103,1104,1106,1108,1111],{"class":67,"line":92},[65,1105,117],{"class":116},[65,1107,121],{"class":120},[65,1109,1110],{"class":129},"make_value",[65,1112,1113],{"class":120},"())\n",[14,1115,345],{},[56,1117,1119],{"className":58,"code":1118,"language":60,"meta":61,"style":61},"10\n",[21,1120,1121],{"__ignoreMap":61},[65,1122,1123],{"class":67,"line":68},[65,1124,1118],{"class":339},[51,1126,1128],{"id":1127},"useful-debugging-commands","Useful debugging commands",[14,1130,1131],{},"These commands are helpful when tracking down the problem:",[56,1133,1135],{"className":58,"code":1134,"language":60,"meta":61,"style":61},"import mymodule; print(mymodule.__file__)\nimport mymodule; print(dir(mymodule))\nhelp(mymodule)\n",[21,1136,1137,1156,1174],{"__ignoreMap":61},[65,1138,1139,1141,1144,1146,1148,1150,1152,1154],{"class":67,"line":68},[65,1140,86],{"class":78},[65,1142,1143],{"class":82}," mymodule; ",[65,1145,117],{"class":116},[65,1147,121],{"class":120},[65,1149,130],{"class":129},[65,1151,152],{"class":120},[65,1153,897],{"class":896},[65,1155,900],{"class":120},[65,1157,1158,1160,1162,1164,1166,1168,1170,1172],{"class":67,"line":75},[65,1159,86],{"class":78},[65,1161,1143],{"class":82},[65,1163,117],{"class":116},[65,1165,121],{"class":120},[65,1167,124],{"class":116},[65,1169,121],{"class":120},[65,1171,130],{"class":129},[65,1173,133],{"class":120},[65,1175,1176,1179,1181,1183],{"class":67,"line":92},[65,1177,1178],{"class":116},"help",[65,1180,121],{"class":120},[65,1182,130],{"class":129},[65,1184,900],{"class":120},[14,1186,1187],{},"From the command line:",[56,1189,1193],{"className":1190,"code":1191,"language":1192,"meta":61,"style":61},"language-bash shiki shiki-themes material-theme-lighter github-light github-dark","python --version\npip show package_name\n","bash",[21,1194,1195,1204],{"__ignoreMap":61},[65,1196,1197,1200],{"class":67,"line":68},[65,1198,60],{"class":1199},"sbgvK",[65,1201,1203],{"class":1202},"stzsN"," --version\n",[65,1205,1206,1209,1212],{"class":67,"line":75},[65,1207,1208],{"class":1199},"pip",[65,1210,1211],{"class":271}," show",[65,1213,1214],{"class":271}," package_name\n",[14,1216,1217],{},"What they help with:",[29,1219,1220,1226,1232,1238,1244],{},[32,1221,1222,1225],{},[21,1223,1224],{},"mymodule.__file__"," shows which file Python imported",[32,1227,1228,1231],{},[21,1229,1230],{},"dir(mymodule)"," shows the names available in the module",[32,1233,1234,1237],{},[21,1235,1236],{},"help(mymodule)"," gives basic module information",[32,1239,1240,1243],{},[21,1241,1242],{},"python --version"," helps confirm your Python version",[32,1245,1246,1249],{},[21,1247,1248],{},"pip show package_name"," shows the installed package version",[51,1251,1253],{"id":1252},"faq","FAQ",[650,1255,1257],{"id":1256},"what-is-the-difference-between-importerror-and-modulenotfounderror","What is the difference between ImportError and ModuleNotFoundError?",[14,1259,1260,1263],{},[21,1261,1262],{},"ModuleNotFoundError"," means Python cannot find the module.",[14,1265,1266,1268],{},[21,1267,170],{}," means Python found the module but not the specific name inside it.",[650,1270,1272],{"id":1271},"can-circular-imports-cause-this-error","Can circular imports cause this error?",[14,1274,1275],{},"Yes. If two files import each other, one file may try to import a name before it is available.",[650,1277,1279],{"id":1278},"why-does-this-happen-even-though-the-name-is-in-the-file","Why does this happen even though the name is in the file?",[14,1281,1282],{},"Common reasons:",[29,1284,1285,1288,1291,1293],{},[32,1286,1287],{},"you are importing the wrong file",[32,1289,1290],{},"a local filename is conflicting with the real module",[32,1292,43],{},[32,1294,1295],{},"the name is not available when the import runs",[650,1297,1299],{"id":1298},"how-do-i-check-what-names-a-module-provides","How do I check what names a module provides?",[14,1301,1302,1303,1306],{},"Import the module and use ",[21,1304,1305],{},"dir(module_name)"," to list the available names.",[14,1308,648],{},[56,1310,1312],{"className":58,"code":1311,"language":60,"meta":61,"style":61},"import math\nprint(dir(math))\n",[21,1313,1314,1320],{"__ignoreMap":61},[65,1315,1316,1318],{"class":67,"line":68},[65,1317,86],{"class":78},[65,1319,317],{"class":82},[65,1321,1322,1324,1326,1328,1330,1332],{"class":67,"line":75},[65,1323,117],{"class":116},[65,1325,121],{"class":120},[65,1327,124],{"class":116},[65,1329,121],{"class":120},[65,1331,205],{"class":129},[65,1333,133],{"class":120},[51,1335,1337],{"id":1336},"see-also","See also",[29,1339,1340,1346,1350,1355,1360],{},[32,1341,1342],{},[214,1343,1345],{"href":1344},"\u002Ferrors\u002Fimporterror-no-module-named-x-fix\u002F","ImportError: no module named x",[32,1347,1348],{},[214,1349,217],{"href":216},[32,1351,1352],{},[214,1353,1354],{"href":447},"How to import a module in Python",[32,1356,1357],{},[214,1358,1359],{"href":442},"How import works in Python",[32,1361,1362],{},[214,1363,635,1364,638],{"href":634},[21,1365,491],{},[1367,1368,1369],"style",{},"html pre.shiki code .sutJx, html code.shiki .sutJx{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#6A737D;--shiki-default-font-style:inherit;--shiki-dark:#6A737D;--shiki-dark-font-style:inherit}html pre.shiki code .sVHd0, html code.shiki .sVHd0{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#D73A49;--shiki-default-font-style:inherit;--shiki-dark:#F97583;--shiki-dark-font-style:inherit}html pre.shiki code .su5hD, html code.shiki .su5hD{--shiki-light:#90A4AE;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sptTA, html code.shiki .sptTA{--shiki-light:#6182B8;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sP7_E, html code.shiki .sP7_E{--shiki-light:#39ADB5;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .slqww, html code.shiki .slqww{--shiki-light:#6182B8;--shiki-default:#24292E;--shiki-dark:#E1E4E8}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sZMiF, html code.shiki .sZMiF{--shiki-light:#E2931D;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sjJ54, html code.shiki .sjJ54{--shiki-light:#39ADB5;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .s_sjI, html code.shiki .s_sjI{--shiki-light:#91B859;--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .srdBf, html code.shiki .srdBf{--shiki-light:#F76D47;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .s39Yj, html code.shiki .s39Yj{--shiki-light:#39ADB5;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sbsja, html code.shiki .sbsja{--shiki-light:#9C3EDA;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sGLFI, html code.shiki .sGLFI{--shiki-light:#6182B8;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .s_hVV, html code.shiki .s_hVV{--shiki-light:#90A4AE;--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .smGrS, html code.shiki .smGrS{--shiki-light:#39ADB5;--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sbgvK, html code.shiki .sbgvK{--shiki-light:#E2931D;--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .stzsN, html code.shiki .stzsN{--shiki-light:#91B859;--shiki-default:#005CC5;--shiki-dark:#79B8FF}",{"title":61,"searchDepth":75,"depth":75,"links":1371},[1372,1373,1374,1375,1376,1377,1381,1389,1390,1391,1397],{"id":53,"depth":75,"text":54},{"id":164,"depth":75,"text":165},{"id":221,"depth":75,"text":222},{"id":371,"depth":75,"text":372},{"id":451,"depth":75,"text":452},{"id":641,"depth":75,"text":642,"children":1378},[1379,1380],{"id":652,"depth":92,"text":655},{"id":706,"depth":92,"text":709},{"id":836,"depth":75,"text":837,"children":1382},[1383,1384,1385,1386,1387,1388],{"id":843,"depth":92,"text":844},{"id":861,"depth":92,"text":862},{"id":871,"depth":92,"text":872},{"id":909,"depth":92,"text":910},{"id":941,"depth":92,"text":942},{"id":976,"depth":92,"text":977},{"id":986,"depth":75,"text":987},{"id":1127,"depth":75,"text":1128},{"id":1252,"depth":75,"text":1253,"children":1392},[1393,1394,1395,1396],{"id":1256,"depth":92,"text":1257},{"id":1271,"depth":92,"text":1272},{"id":1278,"depth":92,"text":1279},{"id":1298,"depth":92,"text":1299},{"id":1336,"depth":75,"text":1337},"Master importerror cannot import name fix in our comprehensive Python beginner guide.","md",{},"\u002Ferrors\u002Fimporterror-cannot-import-name-fix",{"title":5,"description":1398},"errors\u002Fimporterror-cannot-import-name-fix","HlrrpeNKvj7xry0nofi08giIbxmiyayxrRTv3iru4Xk",1777585478584]