Category Archives: anaconda

apache won’t stating with Anaconda3 python on windows ImportError: No module named ‘encodings’

    Current thread 0x00001440 (most recent call first):
[Tue Apr 26 14:12:20.813783 2016] [mpm_winnt:crit] [pid 656:tid 568] AH00419: master_main: create child process failed. Exiting.
[Tue Apr 26 14:21:24.500827 2016] [mpm_winnt:notice] [pid 3968:tid 600] AH00455: Apache/2.4.20 (Win32) mod_wsgi/4.5.2 Python/3.5.1 configured -- resuming normal operations
[Tue Apr 26 14:21:24.500827 2016] [mpm_winnt:notice] [pid 3968:tid 600] AH00456: Apache Lounge VC10 Server built: Apr 10 2016 12:20:53
[Tue Apr 26 14:21:24.500827 2016] [core:notice] [pid 3968:tid 600] AH00094: Command line: 'C:\\Apache24\\bin\\httpd.exe -d C:/Apache24'
[Tue Apr 26 14:21:24.500827 2016] [mpm_winnt:notice] [pid 3968:tid 600] AH00418: Parent: Created child process 5712
Fatal Python error: Py_Initialize: unable to load the file system codec
ImportError: No module named 'encodings'

windows path C:\Anaconda3;C:\Anaconda3\Scripts;C:\Anaconda3\Library\bin

Any suggestions with this problem?

apache won’t stating with Anaconda3 python on windows ImportError: No module named ‘encodings’

    Current thread 0x00001440 (most recent call first):
[Tue Apr 26 14:12:20.813783 2016] [mpm_winnt:crit] [pid 656:tid 568] AH00419: master_main: create child process failed. Exiting.
[Tue Apr 26 14:21:24.500827 2016] [mpm_winnt:notice] [pid 3968:tid 600] AH00455: Apache/2.4.20 (Win32) mod_wsgi/4.5.2 Python/3.5.1 configured -- resuming normal operations
[Tue Apr 26 14:21:24.500827 2016] [mpm_winnt:notice] [pid 3968:tid 600] AH00456: Apache Lounge VC10 Server built: Apr 10 2016 12:20:53
[Tue Apr 26 14:21:24.500827 2016] [core:notice] [pid 3968:tid 600] AH00094: Command line: 'C:\\Apache24\\bin\\httpd.exe -d C:/Apache24'
[Tue Apr 26 14:21:24.500827 2016] [mpm_winnt:notice] [pid 3968:tid 600] AH00418: Parent: Created child process 5712
Fatal Python error: Py_Initialize: unable to load the file system codec
ImportError: No module named 'encodings'

windows path C:\Anaconda3;C:\Anaconda3\Scripts;C:\Anaconda3\Library\bin

Any suggestions with this problem?

Import Error: cannot import name _compare_digest in deploying flask API with anaconda python on apache2 + mod_wsgi

I am trying to deploy the flask api on apache2 server with anaconda 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.

my default.config file is

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin [email protected]
    DocumentRoot /var/www/html
    WSGIDaemonProcess brands threads=5 python-path=/home/ubuntu/anaconda2/lib/python2.7/ python-home=/home/ubuntu/anaconda2/
    WSGIScriptAlias / /var/www/html/brands/apirest.wsgi

    <Directory /var/www/brands>
            WSGIProcessGroup apirest
            WSGIApplicationGroup %{GLOBAL}
            Order deny,allow
            Allow from all
    </Directory>


    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG......

the wsgi.conf is

<IfModule mod_wsgi.c>
    WSGIPythonHome /home/ubuntu/anaconda2
    WSGIPythonPath /home/ubuntu/anaconda2/lib/python2.7/.....

and my apirest.wsgi file is

import sys
sys.path.insert(0, '/var/www/html/brands')
from apirest import app as application

How should i be resolving this issue? I have unsuccessfully tried a lot of methods to use flask + apache2 + anaconda.

Import Error: cannot import name _compare_digest in deploying flask API with anaconda python on apache2 + mod_wsgi

I am trying to deploy the flask api on apache2 server with anaconda 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.

my default.config file is

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin [email protected]
    DocumentRoot /var/www/html
    WSGIDaemonProcess brands threads=5 python-path=/home/ubuntu/anaconda2/lib/python2.7/ python-home=/home/ubuntu/anaconda2/
    WSGIScriptAlias / /var/www/html/brands/apirest.wsgi

    <Directory /var/www/brands>
            WSGIProcessGroup apirest
            WSGIApplicationGroup %{GLOBAL}
            Order deny,allow
            Allow from all
    </Directory>


    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG......

the wsgi.conf is

<IfModule mod_wsgi.c>
    WSGIPythonHome /home/ubuntu/anaconda2
    WSGIPythonPath /home/ubuntu/anaconda2/lib/python2.7/.....

and my apirest.wsgi file is

import sys
sys.path.insert(0, '/var/www/html/brands')
from apirest import app as application

How should i be resolving this issue? I have unsuccessfully tried a lot of methods to use flask + apache2 + anaconda.

No pointing to the right python Flask

I am making flask server on ubuntu, but it always runs system python instead anaconda's one. Though the anaconda one in path. I get this error.

/var/log/apache2/error.log

[Fri Mar 04 01:31:00.155996 2016] [:error] [pid 10662:tid 140298084656896] [client 122.161.60.26:37123] mod_wsgi (pid=10662): Target WSGI script '/var/www/FlaskApps/FlaskApps.wsgi' cannot be loaded as Python module.
[Fri Mar 04 01:31:00.156024 2016] [:error] [pid 10662:tid 140298084656896] [client 122.161.60.26:37123] mod_wsgi (pid=10662): Exception occurred processing WSGI script '/var/www/FlaskApps/FlaskApps.wsgi'.
[Fri Mar 04 01:31:00.156046 2016] [:error] [pid 10662:tid 140298084656896] [client 122.161.60.26:37123] Traceback (most recent call last):
[Fri Mar 04 01:31:00.156060 2016] [:error] [pid 10662:tid 140298084656896] [client 122.161.60.26:37123]   File "/var/www/FlaskApps/FlaskApps.wsgi", line 8, in <module>
[Fri Mar 04 01:31:00.156117 2016] [:error] [pid 10662:tid 140298084656896] [client 122.161.60.26:37123]     from home import app as application
[Fri Mar 04 01:31:00.156126 2016] [:error] [pid 10662:tid 140298084656896] [client 122.161.60.26:37123]   File "/var/www/FlaskApps/note_app/home.py", line 4, in <module>
[Fri Mar 04 01:31:00.156157 2016] [:error] [pid 10662:tid 140298084656896] [client 122.161.60.26:37123]     from models import UsersLoginInfo,Base
[Fri Mar 04 01:31:00.156164 2016] [:error] [pid 10662:tid 140298084656896] [client 122.161.60.26:37123]   File "/var/www/FlaskApps/note_app/models.py", line 2, in <module>
[Fri Mar 04 01:31:00.156191 2016] [:error] [pid 10662:tid 140298084656896] [client 122.161.60.26:37123]     from sqlalchemy import Column,Integer,String
[Fri Mar 04 01:31:00.156207 2016] [:error] [pid 10662:tid 140298084656896] [client 122.161.60.26:37123] ImportError: No module named sqlalchemy

In configuration file I have changed to direct it to anaconda's python:

[email protected]:/var/www/FlaskApps# pwd 
/var/www/FlaskApps
[email protected]:/var/www/FlaskApps# cat FlaskApps.wsgi 
#!/root/anaconda2/bin/python2.7
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/FlaskApps/note_app/")

# home points to the home.py file
from home import app as application
application.secret_key = "somesecretsessionkey"

Problem: Although I have installed anaconda python and it has sqlalchemy. The fact that it is showing import error, means it is not directed to anaconda's python. How to of fix this?

$ echo $PATH
/root/anaconda2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

mod_wsgi & anaconda – pythonpath error

I'm getting the following errors when trying to start my app.

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site

running my anaconda python and doing

import site
site

gives me the following

<module 'site' from '/opt/common/external/anaconda/2.3.0/lib/python2.7/site.pyc'>

This is my app.conf

WSGIDaemonProcess itam python-path=/opt/itam:/opt/common/external/anaconda/2.3.0/bin:/opt/common/external/python_modules
WSGIProcessGroup itam
WSGIScriptAlias / /opt/itam/itam/wsgi.py

<Directory /opt/itam/itam>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

mod_wsgi & anaconda – pythonpath error

I'm getting the following errors when trying to start my app.

Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site

running my anaconda python and doing

import site
site

gives me the following

<module 'site' from '/opt/common/external/anaconda/2.3.0/lib/python2.7/site.pyc'>

This is my app.conf

WSGIDaemonProcess itam python-path=/opt/itam:/opt/common/external/anaconda/2.3.0/bin:/opt/common/external/python_modules
WSGIProcessGroup itam
WSGIScriptAlias / /opt/itam/itam/wsgi.py

<Directory /opt/itam/itam>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

How to deploy Django project in Apache+mod_wsgi

I have a django project which uses numpy and other library. I use Anaconda (2.7 32bit) as Python interpreter. I want to deploy the Django project using Apache+mod_wsgi.

First, I install Apache24(VC9, 32bit) + Mod_wsgi. Below are my settings of httpd and wsgi files

In C:\Apache24\conf\httpd.conf, I add/revise the following

    Listen 8980
    LoadModule wsgi_module modules/mod_wsgi.so

    WSGIPythonHome "C:/Anaconda"

    WSGIPythonPath "C:/Apache24/htdocs/a;C:/Anaconda/libs;C:/Anaconda/Lib/site-packages"


    <VirtualHost *:8980> 
        ServerName 127.0.0.1

        WSGIScriptAlias / C:/Apache24/htdocs/a/project/wsgi.py
        <Directory C:/Apache24/htdocs/a/project>
        <Files wsgi.py>
            Require all granted
        </Files>
        </Directory>


        Alias /static "C:/Apache24/htdocs/a/static/static_root/"

        <Directory C:/Apache24/htdocs/a/static/static_root>
        Require all granted
        </Directory>

    </VirtualHost>

in wsgi.py in Django project:

import sys
sys.path.append('C:/Apache24/htdocs/a') 
sys.path.append('C:/Apache24/htdocs/a/project') 

import site
site.addsitedir('C:\\Anaconda\\Lib\\site-packages')


import os

from django.core.wsgi import get_wsgi_application

# os.environ.setdefault("DJANGO_SETTINGS_MODULE", "philips_crossover.settings")
os.environ["DJANGO_SETTINGS_MODULE"]= "project.settings"

application = get_wsgi_application()

My probem is that when I access 127.0.0.1:8980, I get errors.

in C:\Apache24\logs\errors.log

Traceback (most recent call last):
  File "C:/Apache24/htdocs/a/project/wsgi.py", line 20, in <module>
    from django.core.wsgi import get_wsgi_application
  File "C:\\Anaconda\\lib\\site-packages\\django\\core\\wsgi.py", line 2, in <module>
    from django.core.handlers.wsgi import WSGIHandler
  File "C:\\Anaconda\\lib\\site-packages\\django\\core\\handlers\\wsgi.py", line 11, in <module>
    from django import http
  File "C:\\Anaconda\\lib\\site-packages\\django\\http\\__init__.py", line 1, in <module>
    from django.http.cookie import SimpleCookie, parse_cookie
  File "C:\\Anaconda\\lib\\site-packages\\django\\http\\cookie.py", line 6, in <module>
    from django.utils.encoding import force_str
  File "C:\\Anaconda\\lib\\site-packages\\django\\utils\\encoding.py", line 11, in <module>
    from django.utils.six.moves.urllib.parse import quote, unquote
  File "C:\\Anaconda\\lib\\site-packages\\django\\utils\\six.py", line 90, in __get__
    result = self._resolve()
  File "C:\\Anaconda\\lib\\site-packages\\django\\utils\\six.py", line 158, in _resolve
    module = _import_module(self.mod)
  File "C:\\Anaconda\\lib\\site-packages\\django\\utils\\six.py", line 80, in _import_module
    __import__(name)
  File "C:\\Anaconda\\lib\\urllib.py", line 26, in <module>
    import socket
  File "C:\\Anaconda\\lib\\socket.py", line 47, in <module>
    import _socket
ImportError: DLL load failed: The specified procedure could not be found.

How do I use a conda environment with mod_wsgi?

My first post, and I'm new to both Python and Apache, so please go easy on me. I have a Python web application in a conda environment that serves up content just fine using Flask. Now I need to serve everything with Apache instead of Flask. I can get Apache to run Python with mod_wsgi, but only with virtualenv. I tried installing virtualenv with Anaconda, but I received a warning that such a setup is unsupported and not recommended. So my question is this:

How do I set up Apache to run my application in a conda environment?

Here, there's a section on working with virtual environments, and it says I need to enter a line into my wsgi file showing where to find activate_this.py. A virtualenv virtual environment has activate_this.py, but a conda environment does not. It seems that without the right instructions for activating the virtual environment, I'm just getting error 500 in my browser and "Import error: no module named flask" in my httpd error_log.

This is in my httpd.conf file:

<VirtualHost *:80>
     DocumentRoot /var/www
     WSGIScriptAlias / var/www/tsm.wsgi
     <Directory /var/www/tsm>
     Order allow,deny
     Allow from all
     </Directory>
</VirtualHost>

And here is tsm.wsgi:

import sys
import site
site.addsitedir('~/.conda/envs/tsm/lib/python2.7/site-packages')
sys.path.insert(0, '/var/www/tsm/server/time_series_machine')
sys.stdout = sys.stderr
from app import app as application

Any ideas? Thanks for any help you can provide.

When I try and run pyspark.cmd I get the error message "find: ‘version’: No such file or directory"

I'm trying to get started with Apache Spark. I'd like to use it via python. However, when I run pyspark from the command line I get the following error message:

C:\Programs\Apache\Spark\spark-1.2.0-bin-hadoop2.4\bin>pyspark.cmd
Running python with PYTHONPATH=C:\Programs\Apache\Spark\spark-1.2.0-bin-hadoop2.
4\bin\..\python\lib\py4j-0.8.2.1-src.zip;C:\Programs\Apache\Spark\spark-1.2.0-bi
n-hadoop2.4\bin\..\python;
Python 2.7.8 |Anaconda 2.1.0 (32-bit)| (default, Jul  2 2014, 15:13:35) [MSC v.1
500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
find: 'version': No such file or directory
else was unexpected at this time.
Traceback (most recent call last):
  File "C:\Programs\Apache\Spark\spark-1.2.0-bin-hadoop2.4\bin\..\python\pyspark
\shell.py", line 45, in <module>
    sc = SparkContext(appName="PySparkShell", pyFiles=add_files)
  File "C:\Programs\Apache\Spark\spark-1.2.0-bin-hadoop2.4\python\pyspark\contex
t.py", line 102, in __init__
    SparkContext._ensure_initialized(self, gateway=gateway)
  File "C:\Programs\Apache\Spark\spark-1.2.0-bin-hadoop2.4\python\pyspark\contex
t.py", line 211, in _ensure_initialized
    SparkContext._gateway = gateway or launch_gateway()
  File "C:\Programs\Apache\Spark\spark-1.2.0-bin-hadoop2.4\python\pyspark\java_g
ateway.py", line 73, in launch_gateway
    raise Exception(error_msg)
Exception: Launching GatewayServer failed with exit code 255!
Warning: Expected GatewayServer to output a port, but found no output.

When I try and run the scala interface by running spark-shell I get the message:

find: 'version': No such file or directory
else was unexpected at this time.

I cant find any info on this error online, other than

which turned out to be a dead end. https://issues.apache.org/jira/browse/SPARK-3808 Please help!