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