I just installed QGIS (2.18) using the OSGeo4W-installer (64-bit). When I use the python-console in QGIS it is possible to run the 'import numpy' statement and to use numpy.

When I open python in the command-window of windows or when I create a stand-alone script it is impossible to import numpy. It gives this:

 ImportError: No module named _ctypes

This is strange because it is the same installation of python and ctypes is installed during the installation of QGIS. Any ideas how to get numpy working in standalone scripts?

Some additional information: I used the default installation of the OSGeo4W installer and my pythonpath is set to:


and python is added to the path-variable:

  • Does it work when you use OSGeo4W Shell command window?
    – Joseph
    Jan 25, 2017 at 15:28
  • Yes, I just tested it and it works.
    – da_re
    Jan 25, 2017 at 15:34
  • But I want to get it work in a stand-alone script, I need python outside the shell...Any ideas? :)
    – da_re
    Jan 26, 2017 at 8:52
  • If it works with the shell you can also import os with python and do os.system("your_command") Jan 27, 2017 at 9:44

1 Answer 1


The problem is solved. I added the location of _ctypes.pyd to the systemvariable pythonpath and now it works perfectly!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.