{"action":"created","issue":{"url":"https://api.github.com/repos/GrahamDumpleton/mod_wsgi/issues/127","repository_url":"https://api.github.com/repos/GrahamDumpleton/mod_wsgi","labels_url":"https://api.github.com/repos/GrahamDumpleton/mod_wsgi/issues/127/labels{/name}","comments_url":"https://api.github.com/repos/GrahamDumpleton/mod_wsgi/issues/127/comments","events_url":"https://api.github.com/repos/GrahamDumpleton/mod_wsgi/issues/127/events","html_url":"https://github.com/GrahamDumpleton/mod_wsgi/issues/127","id":145337394,"number":127,"title":"Import Error: cannot import name _compare_digest in deploying flask API with anaconda python on apache2 + mod_wsgi","user":{"login":"awhitesong","id":8583951,"avatar_url":"https://avatars.githubusercontent.com/u/8583951?v=3","gravatar_id":"","url":"https://api.github.com/users/awhitesong","html_url":"https://github.com/awhitesong","followers_url":"https://api.github.com/users/awhitesong/followers","following_url":"https://api.github.com/users/awhitesong/following{/other_user}","gists_url":"https://api.github.com/users/awhitesong/gists{/gist_id}","starred_url":"https://api.github.com/users/awhitesong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awhitesong/subscriptions","organizations_url":"https://api.github.com/users/awhitesong/orgs","repos_url":"https://api.github.com/users/awhitesong/repos","events_url":"https://api.github.com/users/awhitesong/events{/privacy}","received_events_url":"https://api.github.com/users/awhitesong/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-04-02T05:12:27Z","updated_at":"2016-04-02T09:20:19Z","closed_at":null,"body":"I am trying to deploy the flask api on apache2 server with anaconda python and mod_wsgi and facing many problems. My mod_wsgi is compiled from source with anaconda's python (setup.py) but everytime my server on browser shows error 500. In the logs `Import Error: cannot import name _compare_digest` seems to be causing the problem. \r\n\r\nThe error log\r\n\r\n    [Sat Apr 02 02:23:40.700719 2016] [wsgi:error] [pid 25581:tid 140329290245888] [client xx.xx.xx.xx:60400]     import hmac, referer: http://ec2-xx-xx-xx-xx.xx-xx-xx.compute.amazonaws.com \r\n    [Sat Apr 02 02:23:40.700727 2016] [wsgi:error] [pid 25581:tid 140329290245888] [client xx.xx.xx.xx:60400]   File \"/home/ubuntu/anaconda2/lib/python2.7/hmac.py\", line 8, in <module>,     referer: http://ec2-xx-xx-xx-xx.xx-xx-xx.compute.amazonaws.com\r\n    [Sat Apr 02 02:23:40.700740 2016] [wsgi:error] [pid 25581:tid 140329290245888] [client xx.xx.xx.xx:60400]     from operator import _compare_digest as compare_digest, referer: referer: http://ec2-xx-xx-xx-xx.xx-xx-xx.compute.amazonaws.com\r\n    [Sat Apr 02 02:23:40.700760 2016] [wsgi:error] [pid 25581:tid 140329290245888] [client xx.xx.xx.xx:60400] ImportError: cannot import name _compare_digest, referer: http://ec2-xx-xx-xx-xx.xx-xx-xx.compute.amazonaws.com\r\n\r\n\r\nSystem info:\r\n\r\n1. `lsb_release -a`\r\n\r\n        Distributor ID:\tUbuntu\r\n        Description:\tUbuntu 14.04.4 LTS\r\n        Release:\t    14.04\r\n        Codename:\t    trusty\r\n\r\n2.  Anaconda has python version 2.7.11 in `/home/ubuntu/anaconda2/bin` and system has python 2.7.6 in /usr/bin/\r\n\r\nThings i've done:\r\n\r\n1. First I purge removed `libapache2-mod-wsgi` which might cause conflicting python problems (are there any other system packages?) and then i installed mod_wsgi from source with anaconda's python. (`python setup.py install`)\r\n\r\n2. After that, I created `wsgi.load` myself in `/etc/apache2/mods-available` which includes \r\n        \r\n        LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so\r\n\r\n3. I ran `mod_wsgi-express install module`  which gave \r\n        \r\n        LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi-py27.so\r\n        WSGIPythonHome /home/ubuntu/anaconda2\r\n        \r\n    So my `/usr/lib/apache2/modules` also has `mod_wsgi-py27.so` along with `mod_wsgi.so` but i've included the latter one in `LoadModule`\r\n\r\n4. I DON'T have any `mod_python` or or `python.conf` installed for any conflicts. (not sure here where i'll see `python.conf`. Also should i install these?)  \r\n\r\n5. `wsgi.conf` includes the suitable `WSGIPythonHome` and `WSGIPythonPath`\r\n\r\n        <IfModule mod_wsgi.c>\r\n            WSGIPythonHome /home/ubuntu/anaconda2\r\n            WSGIPythonPath /home/ubuntu/anaconda2/lib/python2.7/site-packages\r\n        </IfModule>\r\n\r\n\r\n6. My `default.conf` file is \r\n\r\n    <VirtualHost *:80>\r\n        # The ServerName directive sets the request scheme, hostname and port that\r\n        # the server uses to identify itself. This is used when creating\r\n        # redirection URLs. In the context of virtual hosts, the ServerName\r\n        # specifies what hostname must appear in the request's Host: header to\r\n        # match this virtual host. For the default virtual host (this file) this\r\n        # value is not decisive as it is used as a last resort host regardless.\r\n        # However, you must set it for any further virtual host explicitly.\r\n        #ServerName www.example.com\r\n\r\n        ServerAdmin webmaster@localhost\r\n        DocumentRoot /var/www/html\r\n        WSGIDaemonProcess brands threads=5 \r\n        WSGIScriptAlias / /var/www/html/brands/apirest.wsgi\r\n\r\n        <Directory /var/www/brands>\r\n                WSGIProcessGroup apirest\r\n                WSGIApplicationGroup %{GLOBAL}\r\n                Order deny,allow\r\n                Allow from all\r\n        </Directory>\r\n\r\n\r\n        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,\r\n        # error, crit, alert, emerg.\r\n        # It is also possible to configure the loglevel for particular\r\n        # modules, e.g.\r\n        #LogLevel info ssl:warn\r\n\r\n        ErrorLog ${APACHE_LOG_DIR}/error.log\r\n        CustomLog ${APACHE_LOG......\r\n\r\n7. Finally, my `apirest.wsgi` file is \r\n    \r\n        import sys\r\n        sys.path.insert(0, '/var/www/html/brands')\r\n        from apirest import app as application\r\n\r\nPlease tell how should i be resolving this. What could be the issue with `mod_wsgi` for detecting anaconda's python? Btw anaconda's python has `_compare_digest`. I can import it separately. A lot of people online are having the same problem but there isn't any concrete solution anywhere to this. Thanks."},"comment":{"url":"https://api.github.com/repos/GrahamDumpleton/mod_wsgi/issues/comments/204679244","html_url":"https://github.com/GrahamDumpleton/mod_wsgi/issues/127#issuecomment-204679244","issue_url":"https://api.github.com/repos/GrahamDumpleton/mod_wsgi/issues/127","id":204679244,"user":{"login":"GrahamDumpleton","id":507637,"avatar_url":"https://avatars.githubusercontent.com/u/507637?v=3","gravatar_id":"","url":"https://api.github.com/users/GrahamDumpleton","html_url":"https://github.com/GrahamDumpleton","followers_url":"https://api.github.com/users/GrahamDumpleton/followers","following_url":"https://api.github.com/users/GrahamDumpleton/following{/other_user}","gists_url":"https://api.github.com/users/GrahamDumpleton/gists{/gist_id}","starred_url":"https://api.github.com/users/GrahamDumpleton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GrahamDumpleton/subscriptions","organizations_url":"https://api.github.com/users/GrahamDumpleton/orgs","repos_url":"https://api.github.com/users/GrahamDumpleton/repos","events_url":"https://api.github.com/users/GrahamDumpleton/events{/privacy}","received_events_url":"https://api.github.com/users/GrahamDumpleton/received_events","type":"User","site_admin":false},"created_at":"2016-04-02T09:20:19Z","updated_at":"2016-04-02T09:20:19Z","body":"Right after the ``WSGIDaemonProcess`` directive would be best place."}}