cannot import name multiarray Django Apache2
Question: I am currently running a django app on an ec2 with apache. The app works fine
when I run it using djangos runserver command. However I receive a 'cannot
import name multiarray' when I run it using apache. I have tried reinstalling
numpy and various packages many times and have still not had any luck. Below
is my .conf file for apache. I am using python3.4 and have recently updated
pip within my venv. I can provide more information if necessary.

    
    
        Include conf-available/serve-cgi-bin.conf
        WSGISCRIPTALIAS /site /home/ubuntu/site/initsite/wsgi.py
        WSGIDaemonProcess site_group threads=15 display-name=%{GROUP} python-path='/home/ubuntu/site:/home/ubuntu/site/envsite/lib/python3.4/site-packages'
        <Directory /home/ubuntu/site>
               <files wsgi.py>
                  Require all granted
                </Files>
            </Directory>
            <Location /site>
                 WSGIProcessGroup site_group    
            </Location>
            Alias /site1/ /home/ubuntu/site/fullsite/static/css
            <Directory /home/ubuntu/site/fullsite/static/css>
                Require all granted
                AllowOverride All
            </Directory>
    

Traceback:

    
    
    File "/home/ubuntu/site/envsite/lib/python3.4/site-packages/django/core/handlers/exception.py" in inner
      39.             response = get_response(request)
    
    File "/home/ubuntu/site/envsite/lib/python3.4/site-packages/django/core/handlers/base.py" in _get_response
      172.         resolver_match = resolver.resolve(request.path_info)
    
    File "/home/ubuntu/site/envsite/lib/python3.4/site-packages/django/urls/resolvers.py" in resolve
      270.             for pattern in self.url_patterns:
    
    File "/home/ubuntu/site/envsite/lib/python3.4/site-packages/django/utils/functional.py" in __get__
      35.         res = instance.__dict__[self.name] = self.func(instance)
    
    File "/home/ubuntu/site/envsite/lib/python3.4/site-packages/django/urls/resolvers.py" in url_patterns
      313.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
    
    File "/home/ubuntu/site/envsite/lib/python3.4/site-packages/django/utils/functional.py" in __get__
      35.         res = instance.__dict__[self.name] = self.func(instance)
    
    File "/home/ubuntu/site/envsite/lib/python3.4/site-packages/django/urls/resolvers.py" in urlconf_module
      306.             return import_module(self.urlconf_name)
    
    File "/usr/lib/python2.7/importlib/__init__.py" in import_module
      37.     __import__(name)
    
    File "/home/ubuntu/site/initSite/urls.py" in <module>
      21.     url(r'', include('fullSite.urls')),
    
    File "/home/ubuntu/site/envsite/lib/python3.4/site-packages/django/conf/urls/__init__.py" in include
      50.         urlconf_module = import_module(urlconf_module)
    
    File "/usr/lib/python2.7/importlib/__init__.py" in import_module
      37.     __import__(name)
    
    File "/home/ubuntu/site/fullSite/urls.py" in <module>
      2. from . import views
    
    File "/home/ubuntu/site/fullSite/views.py" in <module>
      1. import numpy as np
    
    File "/home/ubuntu/site/envsite/lib/python3.4/site-packages/numpy/__init__.py" in <module>
      180.     from . import add_newdocs
    
    File "/home/ubuntu/site/envsite/lib/python3.4/site-packages/numpy/add_newdocs.py" in <module>
      13. from numpy.lib import add_newdoc
    
    File "/home/ubuntu/site/envsite/lib/python3.4/site-packages/numpy/lib/__init__.py" in <module>
      8. from .type_check import *
    
    File "/home/ubuntu/site/envsite/lib/python3.4/site-packages/numpy/lib/type_check.py" in <module>
      11. import numpy.core.numeric as _nx
    
    File "/home/ubuntu/site/envsite/lib/python3.4/site-packages/numpy/core/__init__.py" in <module>
      14. from . import multiarray
    
    Exception Type: ImportError at /
    Exception Value: cannot import name multiarray
    

drwxrwxr-x 5 ubuntu ubuntu 4096 Oct 3 22:31 site


Answer: I can possibly spot three issues that may effect your setup.

Your virutalenv is placed inside your project itself, this in my experience
sometimes leads to conflicts. Virtualenvs and the project should always be
separated. May I suggest a structures such as:

/home/ubuntu/site - django project files /home/ubuntu/virtualenv/ - for the
virtualenv

The second issue is that you have placed the site and the virtualenv inside a
user's home directly. Though you have set the top level directory permissions
correctly, it may still be very likely that sub folders, files inside
`/home/ubuntu/site` or `/home/ubuntu/virtualenv/` may be inaccessible to the
apache user. This is very likely to happen if you made additions changes after
the initial permissions were set.

The third issue is that you may have a corrupted numpy installation, please
uninstall and install again and make sure to use pip3 instead of pip. To be
more specific: `pip3 install numpy`

