8

I'm running Django at a virtual environment targeting Python 3.4 using mod_wsgi. I have numpy 1.9 and I'm getting this error:

**Request Method:   GET
Django Version: 1.7.1
Exception Type: ImportError
Exception Value:    
cannot import name multiarray
Exception Location: /var/www/mapsite/lib/python3.4/site-packages/numpy/core/__init__.py in <module>, line 6
Python Executable:  /usr/bin/python
Python Version: 2.7.5
Python Path:    
['/var/www/mapsite/lib/python3.4/site-packages',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages/PILcompat',
 '/usr/lib/python2.7/dist-packages/gtk-2.0',
 '/usr/lib/pymodules/python2.7',
 '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode',
 '/var/www/mysite']
Server time:    Wed, 3 Dec 2014 09:07:24 +0000**

Plesae advice

user903772
  • 1,554
  • 5
  • 32
  • 55

2 Answers2

0

First you need to make sure you are in the right environment where you installed numpy, Django, etc. Base on your provided information, I'm assuming you have a virtualenv and currently developing your application. If the assumption is right, you can follow this steps.

You don't need Apache for this.

  1. Source you virtualenv, source /path/to/env/bin/activate and go to you project directory.
  2. Make sure you have all the package you need, pip freeze will show you, install if necessary.
  3. Run the built in server from Django, python manage.py runserver
  4. Go to your browser: http://localhost:8000

Voila !

zkanda
  • 714
  • 1
  • 6
  • 5
  • Yes, you are right, but only useing manage.py to start web server. I have the same error message, but after start httpd(I'm sure that I have a virtualenv). Anyone can explain this? – FavorMylikes Feb 10 '17 at 16:20
  • "You don't need Apache" is a strong affirmation. I mean, if you don't want to have the site in production, yeah, no need for Apache. But if you want the site to be "production", then definitely run away from `runserver`. – MariusSiuram Dec 19 '17 at 10:24
0

You should tweak your Apache and/or mod_wsgi configuration.

In the lines you show, one can see that a Python 2.7 is being used but is being combined with packages from a virtual environment of Python 3.4. That is completely wrong and should be addressed.

To fix that, the simplest way is to use the following python binary:

/var/www/mapsite/bin/python3.4

instead of the default

/usr/bin/python

Using the explicit virtual environment binary is the way to go in those situations (at least, it has worked for me in a lot of similar scenarios).

MariusSiuram
  • 3,380
  • 1
  • 21
  • 40