Can't "import urllib.request, urllib.parse, urllib.error"
<p>I trying to convert my project to python3.</p>

<p>My server script is server.py:</p>

<pre><code>#!/usr/bin/env python
#-*-coding:utf8-*-

import http.server
import os, sys
server = http.server.HTTPServer
handler = http.server.CGIHTTPRequestHandler
server_address = ("", 8080)
#handler.cgi_directories = [""]
httpd = server(server_address, handler)
httpd.serve_forever()
</code></pre>

<p>But when I try:</p>

<pre><code>import urllib.request, urllib.parse, urllib.error
</code></pre>

<p>I get this in terminal of python3 ./server.py:</p>

<pre class="lang-none prettyprint-override"><code>    import urllib.request, urllib.parse, urllib.error
ImportError: No module named request
127.0.0.1 - - [18/Sep/2016 22:47:18] CGI script exit status 0x100
</code></pre>

<p>How can I do this?</p>

<p>Your shebang suggests that code should be run by <code>python</code> binary, which is historically associated with Python 2.x releases.</p>

<p>Simply change first line to:</p>

<pre><code>#!/usr/bin/env python3
</code></pre>

python python-3.x urllib 2to3