The 2.7 images on Docker Hub should be fixed now. Still have to update the 3.X versions.
So pull latest and try again. Graham > On 25 Nov 2015, at 1:09 PM, Collin Jackson <[email protected]> wrote: > > I get the same PATH when I run the script with either method > (/.whiskey/virtualenv/bin:/usr/local/python/bin:/usr/local/apache/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin). > > I tried adding mod_wsgi to the requirements.txt, but pip says that the > requirement is already up-to-date and located in > /usr/local/python/lib/python2.7/site-packages > > On Tuesday, November 24, 2015 at 8:03:55 PM UTC-6, Graham Dumpleton wrote: > Okay. I think I might know what the problem is. > > For now, add: > > mod_wsgi > > to your requirements.txt file. > > I think that will fix things. > > Graham > > On 25 Nov 2015, at 12:34 PM, Graham Dumpleton <[email protected] > <javascript:>> wrote: > > Just to be sure, can you explicitly pull the latest image to make sure you > have it, in case you picked up an intermediate image when I was quickly > making changes and had broken something. Then rebuild your derived image. > > BTW, what is PATH environment variable set to in both cases, shell and script? > > Graham > > > On 25 Nov 2015, at 12:24 PM, Collin Jackson <[email protected] > <javascript:>> wrote: > > Other than the mentioned sys.path.append(), there are only module imports > (all of which are from the standard library). > > Here is sys.path when running the default mod_wsgi docker command (docker run > image-name): > ['/app/Middleware', '/usr/local/python/lib/python27.zip', > '/usr/local/python/lib/python2.7', > '/usr/local/python/lib/python2.7/plat-linux2', > '/usr/local/python/lib/python2.7/lib-tk', > '/usr/local/python/lib/python2.7/lib-old', > '/usr/local/python/lib/python2.7/lib-dynload', > '/usr/local/python/lib/python2.7/site-packages', '/opt/C3STEM/Middleware/'] > > Here is sys.path when running the script using Python from the shell in the > container: > ['/app/Middleware', '/.whiskey/virtualenv/lib/python27.zip', > '/.whiskey/virtualenv/lib/python2.7', > '/.whiskey/virtualenv/lib/python2.7/plat-linux2', > '/.whiskey/virtualenv/lib/python2.7/lib-tk', > '/.whiskey/virtualenv/lib/python2.7/lib-old', > '/.whiskey/virtualenv/lib/python2.7/lib-dynload', > '/usr/local/python/lib/python2.7', > '/usr/local/python/lib/python2.7/plat-linux2', > '/usr/local/python/lib/python2.7/lib-tk', > '/.whiskey/virtualenv/lib/python2.7/site-packages', > '/usr/local/python/lib/python2.7/site-packages', '/opt/C3STEM/Middleware/'] > > It looks to me like the first case is not using the virtual environment, > although I'm no Python expert. > > On Tuesday, November 24, 2015 at 7:04:46 PM UTC-6, Graham Dumpleton wrote: > What do you have at the start of c3stemserver.py besides: > > sys.path.append('/opt/C3STEM/Middleware/‘) > > Are there any other updates sys.path or does the code do anything with > site.addsitedir()? > > What is sys.path just before attempt module in real application and is that > different to what you see in python from shell? > > Graham > > On 25 Nov 2015, at 11:29 AM, Collin Jackson <collinj...@ <>gmail.com > <http://gmail.com/>> wrote: > > Actually, it's the opposite case. When I get into the container and run the > script directly with Python, the import succeeds. > > On Tuesday, November 24, 2015 at 6:24:08 PM UTC-6, Graham Dumpleton wrote: > Can you clarify that you are saying that when you get into the container with > mod_wsgi-docker-shell and run Python interpreter directly, or by running a > script manually, that the imports fail there as well. > > If yes, can you from the interpreter under that shell, show what sys.path is > for the interpreter, plus what path you find the cherrypy package installed > under in the system. Give a ‘ls -las’ of the parent and package directory > where cherrypy is installed. > > Thanks. > > Graham > > On 24 Nov 2015, at 3:52 AM, Collin Jackson <collinj...@ <>gmail.com > <http://gmail.com/>> wrote: > > Changing the working directory solved the issue with relative file imports, > so thank you for that input. > > Unfortunately, I am now running into the problem that I originally thought I > was having. My script is failing during import of cherrypy, even though I > have confirmed that it was installed both globally and in the virtual > environment in the docker container. When I run my wsgi script using python > (i.e. python script-name), I do not encounter the import issue. However, I > tried running the script using mod_wsgi-express start-server script-name and > again ran into the import issue (in both cases, I followed your advice above > to get a shell inside the container). Additionally, I commented out the line > that imports cherrypy to see if it was a problem specific to cherrypy, but I > also have the same issue later in the script when I try to import bson. > > In case it may be helpful, I have included the output and stacktrace for the > ImportError: > $ docker run -it --rm wsgi > Server URL : http://localhost/ <http://localhost/> > Server Root : /tmp/mod_wsgi-localhost:80:0 > Server Conf : /tmp/mod_wsgi-localhost:80:0/httpd.conf > Error Log File : /dev/stderr (warn) > Startup Log File : /dev/stderr > Request Capacity : 5 (1 process * 5 threads) > Request Timeout : 60 (seconds) > Queue Backlog : 100 (connections) > Queue Timeout : 45 (seconds) > Server Capacity : 20 (event/worker), 20 (prefork) > Server Backlog : 500 (connections) > Locale Setting : en_US.UTF-8 > [Mon Nov 23 16:05:00.970167 2015] [mpm_event:notice] [pid 19:tid > 140041923430144] AH00489: Apache/2.4.17 (Unix) mod_wsgi/4.4.21 Python/2.7.10 > configured -- resuming normal operations > [Mon Nov 23 16:05:00.970530 2015] [core:notice] [pid 19:tid 140041923430144] > AH00094: Command line: 'httpd (mod_wsgi-express) -f > /tmp/mod_wsgi-localhost:80:0/httpd.conf -E /dev/stderr -D > MOD_WSGI_MPM_ENABLE_EVENT_MODULE -D MOD_WSGI_MPM_EXISTS_EVENT_MODULE -D > MOD_WSGI_MPM_EXISTS_WORKER_MODULE -D MOD_WSGI_MPM_EXISTS_PREFORK_MODULE -D > FOREGROUND' > [Mon Nov 23 16:05:01.039537 2015] [wsgi:error] [pid 21:tid 140041923430144] > mod_wsgi (pid=21): Target WSGI script > '/tmp/mod_wsgi-localhost:80:0/handler.wsgi' cannot be loaded as Python module. > [Mon Nov 23 16:05:01.039853 2015] [wsgi:error] [pid 21:tid 140041923430144] > mod_wsgi (pid=21): Exception occurred processing WSGI script > '/tmp/mod_wsgi-localhost:80:0/handler.wsgi'. > [Mon Nov 23 16:05:01.040227 2015] [wsgi:error] [pid 21:tid 140041923430144] > Traceback (most recent call last): > [Mon Nov 23 16:05:01.040487 2015] [wsgi:error] [pid 21:tid 140041923430144] > File "/tmp/mod_wsgi-localhost:80:0/handler.wsgi", line 94, in <module> > [Mon Nov 23 16:05:01.040744 2015] [wsgi:error] [pid 21:tid 140041923430144] > recorder_directory=recorder_directory) > [Mon Nov 23 16:05:01.041024 2015] [wsgi:error] [pid 21:tid 140041923430144] > File > "/usr/local/python/lib/python2.7/site-packages/mod_wsgi/server/__init__.py", > line 1267, in __init__ > [Mon Nov 23 16:05:01.042054 2015] [wsgi:error] [pid 21:tid 140041923430144] > exec(code, self.module.__dict__) > [Mon Nov 23 16:05:01.042338 2015] [wsgi:error] [pid 21:tid 140041923430144] > File "/app/Middleware/c3stemserver.py", line 15, in <module> > [Mon Nov 23 16:05:01.042829 2015] [wsgi:error] [pid 21:tid 140041923430144] > import cherrypy > [Mon Nov 23 16:05:01.043083 2015] [wsgi:error] [pid 21:tid 140041923430144] > ImportError: No module named cherrypy > > > > On Friday, November 20, 2015 at 4:30:25 PM UTC-6, Graham Dumpleton wrote: > If your application is in a sub directory, imports expect to work relative to > that for modules, and even perhaps you expect that to be the current working > directory so relative file access work, you will want to tell mod_wsgi what > the home working directory should be. > > Thus try: > > CMD [ "--working-directory=Middleware", "Middleware/c3stemserver.py"] > > Make sure no strange quotes in that when doing a cut and paste. > > Graham > > On 21 Nov 2015, at 7:31 AM, Collin Jackson <collinj...@ <>gmail.com > <http://gmail.com/>> wrote: > > The script file is in a sub-directory (called "Middleware"), so the > Dockerfile CMD is CMD ["Middleware/c3stemserver.py"]. > > The script does modify sys.path. This line is in the script before the import > sys.path.append('/opt/C3STEM/Middleware/'). > > On Friday, November 20, 2015 at 3:06:44 PM UTC-6, Graham Dumpleton wrote: > Which directory is the wsgi script file in? The top level directory of your > project or a sub directory? > > What do you have for the CMD in your Dockerfile? > > Does your WSGI script file attempt to make modifications to sys.path in any > way? > > Graham > > On 21 Nov 2015, at 3:43 AM, Collin Jackson <collinj...@ <>gmail.com > <http://gmail.com/>> wrote: > > I initially wrote a couple of replies to your comments, but I discovered some > additional important information, so I just deleted those and decided to > start over instead of cluttering the response chain. > > I'm new to the code base I'm working with and didn't realize that the > ImportError was being thrown for an include of a local file, not a package > (so sorry for the confusion). The file to be imported is in the same > directory as the wsgi script. Does the wsgi script get copied to another > directory before running? > > On Friday, November 20, 2015 at 4:31:24 AM UTC-6, Graham Dumpleton wrote: > Sorry for separate messages and not adding to discussion. Don't mean to > confuse you. Best I can do right now. > > If your Dockerfile has USER line in it try commenting it out. > > This is not a permanent solution but will help isolate whether is permissions > issue on writing to application code directory > > Graham > > On 20 Nov 2015, at 2:34 PM, Collin Jackson <[email protected] <>> wrote: > > I'm running mod-wsgi-docker:python-2.7-onbuild and have listed my > requirements in requirements.txt. During build, I can see that the packages > are installed properly, but when I try to run the image, it crashes on the > first non-Standard Library import with an ImportError exception. I can't > figure out what's happening and it's not exactly easy to poke around inside > the container to see what's going on. I noticed that a virtual environment is > created prior to installing the packages (here > <https://github.com/GrahamDumpleton/mod_wsgi-docker/blob/master/2.7/build.sh#L87>), > but I imagine that if this is the issue, other users would have the same > issue. Any ideas? > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to modwsgi+u...@ <>googlegroups.com <http://googlegroups.com/>. > To post to this group, send email to mod...@ <>googlegroups.com > <http://googlegroups.com/>. > Visit this group at http://groups.google.com/group/modwsgi > <http://groups.google.com/group/modwsgi>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <>. > To post to this group, send email to [email protected] <>. > Visit this group at http://groups.google.com/group/modwsgi > <http://groups.google.com/group/modwsgi>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <>. > To post to this group, send email to [email protected] <>. > Visit this group at http://groups.google.com/group/modwsgi > <http://groups.google.com/group/modwsgi>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. > > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <>. > To post to this group, send email to [email protected] <>. > Visit this group at http://groups.google.com/group/modwsgi > <http://groups.google.com/group/modwsgi>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. > > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <>. > To post to this group, send email to [email protected] <>. > Visit this group at http://groups.google.com/group/modwsgi > <http://groups.google.com/group/modwsgi>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. > > > -- > ... > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > Visit this group at http://groups.google.com/group/modwsgi > <http://groups.google.com/group/modwsgi>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/modwsgi. For more options, visit https://groups.google.com/d/optout.
