from visual import * not working (vpython)

AstroBoy picture AstroBoy · Dec 12, 2015 · Viewed 8.5k times · Source

I just downloaded vPython for Python 2.7.9 and got the following error when importing the .visual library:

Traceback (most recent call last):
    File "Untitled", line 1
        from visual import *
    File "C:\Python27\Lib\site-packages\visual\__init__.py", line 3
        from visual.visual_all import * # this statement not included in vis/__init__.py
    File "C:\Python27\Lib\site-packages\visual\visual_all.py", line 10
        from visual_common.cvisual import vector
ImportError: numpy.core.multiarray failed to import

To avoid confusion I tried reinstalling both Python and vPython and made sure that it is the 64-bit version.
I don't know if it's an issue with my python27 files or if I downloaded it wrong. Does anyone know how to solve the error?

Answer

Lee Vaughan picture Lee Vaughan · Aug 14, 2017

The problem is not with the Python installation but with the Numpy module.

From the command line type:

pip install numpy --upgrade

This command will either install the Numpy module if you don't have it, or it will upgrade it to the 64-bit version.

If you have never used pip then navigate to C:/Python27/Lib/site-packages/pip/, double click on the init.py file and then double click on the main.py file. This will install pip which you can then use to download any Python module from the command line by typing:

pip install "module name".