0

I have received the following error when trying to launch the python executable I have created.

Below is how the code is being imported:

from six.moves.urllib.request import Request, urlopen
from six.moves.urllib.error import HTTPError
from six.moves.urllib.parse import urlencode

More specifically, I receive the following when trying to run the code:

  from six.moves.urllib.request import Request, urlopen
ImportError: No module named 'six'

I am using python 3.4 and any help would be greatly appreciated.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
code_legend
  • 3,547
  • 15
  • 51
  • 95
  • 1
    Did you install the `six` library? Are you actively trying to build a polyglot library or should your code only work on Python 2.7? You say you created a Python executable, are you trying to package up a Python application for distribution? – Martijn Pieters Jul 31 '15 at 11:59
  • Did you intend to write `six.moves`? The title suggests you tried to import `urllib.request`. – skyking Jul 31 '15 at 12:00
  • the title is correct. i precisely tried to import from urlib.request my code. i am not preoccupied with 2.7 i am working on 3.4 – code_legend Jul 31 '15 at 12:03
  • Then you don't need to use the `six` library; that is a specialist library for helping you write code that runs on both Python 2 and Python 3 from one codebase. – Martijn Pieters Jul 31 '15 at 12:06

1 Answers1

3

You appear to be trying to write code for Python 3 only. In that case you do not need to use the six library.

six is an external add-on for Python that helps you write code that can run on both Python 2 and Python 3. You'd normally install it explicitly, or copy the library directly into your project (it is just one file and the license explicitly allows for this).

Just import directly from the Python 3 libraries:

from urllib.request import Request, urlopen
from urllib.error import HTTPError
from urllib.parse import urlencode
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343