[Tut] How to Fix Error: No Module Named ‘urlparse’ (Easily) - Printable Version +- Sick Gaming (https://www.sickgaming.net) +-- Forum: Programming (https://www.sickgaming.net/forum-76.html) +--- Forum: Python (https://www.sickgaming.net/forum-83.html) +--- Thread: [Tut] How to Fix Error: No Module Named ‘urlparse’ (Easily) (/thread-100202.html) |
[Tut] How to Fix Error: No Module Named ‘urlparse’ (Easily) - xSicKxBot - 11-08-2022 How to Fix Error: No Module Named ‘urlparse’ (Easily) <div> <div class="kk-star-ratings kksr-auto kksr-align-left kksr-valign-top" data-payload='{"align":"left","id":"874218","slug":"default","valign":"top","ignore":"","reference":"auto","class":"","count":"1","readonly":"","score":"4","best":"5","gap":"5","greet":"Rate this post","legend":"4\/5 - (1 vote)","size":"24","width":"113.5","_legend":"{score}\/{best} - ({count} {votes})","font_factor":"1.25"}'> <div class="kksr-stars"> <div class="kksr-stars-inactive"> <div class="kksr-star" data-star="1" style="padding-right: 5px"> <div class="kksr-icon" style="width: 24px; height: 24px;"></div> </p></div> <div class="kksr-star" data-star="2" style="padding-right: 5px"> <div class="kksr-icon" style="width: 24px; height: 24px;"></div> </p></div> <div class="kksr-star" data-star="3" style="padding-right: 5px"> <div class="kksr-icon" style="width: 24px; height: 24px;"></div> </p></div> <div class="kksr-star" data-star="4" style="padding-right: 5px"> <div class="kksr-icon" style="width: 24px; height: 24px;"></div> </p></div> <div class="kksr-star" data-star="5" style="padding-right: 5px"> <div class="kksr-icon" style="width: 24px; height: 24px;"></div> </p></div> </p></div> <div class="kksr-stars-active" style="width: 113.5px;"> <div class="kksr-star" style="padding-right: 5px"> <div class="kksr-icon" style="width: 24px; height: 24px;"></div> </p></div> <div class="kksr-star" style="padding-right: 5px"> <div class="kksr-icon" style="width: 24px; height: 24px;"></div> </p></div> <div class="kksr-star" style="padding-right: 5px"> <div class="kksr-icon" style="width: 24px; height: 24px;"></div> </p></div> <div class="kksr-star" style="padding-right: 5px"> <div class="kksr-icon" style="width: 24px; height: 24px;"></div> </p></div> <div class="kksr-star" style="padding-right: 5px"> <div class="kksr-icon" style="width: 24px; height: 24px;"></div> </p></div> </p></div> </div> <div class="kksr-legend" style="font-size: 19.2px;"> 4/5 – (1 vote) </div> </div> <p>You may experience the following error message in your Python code when trying to import <code>urlparse</code>:</p> <p><code><strong>ModuleNotFoundError: No module named 'urlparse'</strong></code></p> <pre class="EnlighterJSRAW" data-enlighter-language="python" data-enlighter-theme="" data-enlighter-highlight="5" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">>>> import urlparse Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> import urlparse ModuleNotFoundError: No module named 'urlparse'</pre> <p>How to fix it and what is the reason this error occurs?</p> <div class="wp-block-image"> <figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="601" height="231" src="https://blog.finxter.com/wp-content/uploads/2022/11/image-71.png" alt="" class="wp-image-874242" srcset="https://blog.finxter.com/wp-content/uploads/2022/11/image-71.png 601w, https://blog.finxter.com/wp-content/uploads/2022/11/image-71-300x115.png 300w" sizes="(max-width: 601px) 100vw, 601px" /></figure> </div> <p class="has-global-color-8-background-color has-background">This error usually occurs because <code>urlparse</code> has been renamed to <code>urllib.parse</code>. So you need to <code>pip install urllib</code> and then <code>import urllib</code> and call <code>urllib.parse</code> to make it work.</p> <p>To accomplish this, follow the tutorial outlined next or simply try running this command in your terminal, console, shell, or command line:</p> <pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pip install urllib</pre> <p>After that, you can use urllib.parse like so (<a href="https://docs.python.org/3/library/urllib.parse.html" data-type="URL" data-id="https://docs.python.org/3/library/urllib.parse.html" target="_blank" rel="noreferrer noopener">source</a>):</p> <pre class="EnlighterJSRAW" data-enlighter-language="python" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">from urllib.parse import urlparse urlparse("scheme://netloc/path;parameters?query#fragment") o = urlparse("http://docs.python.org:80/3/library/urllib.parse.html?" "highlight=params#url-parsing") print(o)</pre> <p>Output:</p> <pre class="wp-block-preformatted"><code>ParseResult(scheme='http', netloc='docs.python.org:80', path='/3/library/urllib.parse.html', params='', query='highlight=params', fragment='url-parsing')</code></pre> <p class="has-base-background-color has-background"><img src="https://s.w.org/images/core/emoji/14.0.0/72x72/1f30d.png" alt="?" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <strong>Recommended Tutorial</strong>: <a href="https://blog.finxter.com/how-to-install-urllib3-in-python/" data-type="post" data-id="35997" target="_blank" rel="noreferrer noopener">How to Install urllib in Python?</a></p> </div> https://www.sickgaming.net/blog/2022/11/07/how-to-fix-error-no-module-named-urlparse-easily/ |