{"action":"created","issue":{"url":"https://api.github.com/repos/tiangolo/uwsgi-nginx-flask-docker/issues/22","repository_url":"https://api.github.com/repos/tiangolo/uwsgi-nginx-flask-docker","labels_url":"https://api.github.com/repos/tiangolo/uwsgi-nginx-flask-docker/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/tiangolo/uwsgi-nginx-flask-docker/issues/22/comments","events_url":"https://api.github.com/repos/tiangolo/uwsgi-nginx-flask-docker/issues/22/events","html_url":"https://github.com/tiangolo/uwsgi-nginx-flask-docker/issues/22","id":260636318,"number":22,"title":"Python packages still not available to app after pip install","user":{"login":"raddevon","id":2027711,"avatar_url":"https://avatars2.githubusercontent.com/u/2027711?v=4","gravatar_id":"","url":"https://api.github.com/users/raddevon","html_url":"https://github.com/raddevon","followers_url":"https://api.github.com/users/raddevon/followers","following_url":"https://api.github.com/users/raddevon/following{/other_user}","gists_url":"https://api.github.com/users/raddevon/gists{/gist_id}","starred_url":"https://api.github.com/users/raddevon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raddevon/subscriptions","organizations_url":"https://api.github.com/users/raddevon/orgs","repos_url":"https://api.github.com/users/raddevon/repos","events_url":"https://api.github.com/users/raddevon/events{/privacy}","received_events_url":"https://api.github.com/users/raddevon/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-09-26T14:05:15Z","updated_at":"2017-09-26T20:33:36Z","closed_at":null,"author_association":"NONE","body":"I have additional requirements I need to install for my app. Here's my Dockerfile:\r\n```\r\nFROM tiangolo/uwsgi-nginx-flask:python3.6\r\n\r\nENV STATIC_INDEX 1\r\n\r\nCOPY requirements.txt /app/\r\nRUN pip install -r /app/requirements.txt\r\n\r\nCOPY . /app\r\n```\r\n\r\nEven after rebuilding, the app still can't import my packages. When I bring up the docker container, I get this in the output:\r\n```\r\nTraceback (most recent call last):\r\n  File \"./main.py\", line 4, in <module>\r\n    from flask_cors import CORS\r\n```\r\n\r\nThe build step does show it installing the package.\r\n```\r\nBuilding web\r\nStep 1/5 : FROM tiangolo/uwsgi-nginx-flask:python3.6\r\n ---> 590e17342131\r\nStep 2/5 : ENV STATIC_INDEX 1\r\n ---> Using cache\r\n ---> be704d970645\r\nStep 3/5 : COPY requirements.txt /app/\r\n ---> Using cache\r\n ---> 9a2d06e8c82e\r\nStep 4/5 : RUN pip install -r /app/requirements.txt\r\n ---> Running in 85413afc84ee\r\nCollecting certifi==2017.7.27.1 (from -r /app/requirements.txt (line 1))\r\n  Downloading certifi-2017.7.27.1-py2.py3-none-any.whl (349kB)\r\nCollecting chardet==3.0.4 (from -r /app/requirements.txt (line 2))\r\n  Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB)\r\nRequirement already satisfied: click==6.7 in /usr/local/lib/python3.6/site-packages (from -r /app/requirements.txt (line 3))\r\nRequirement already satisfied: Flask==0.12.2 in /usr/local/lib/python3.6/site-packages (from -r /app/requirements.txt (line 4))\r\nCollecting Flask-Cors==3.0.3 (from -r /app/requirements.txt (line 5))\r\n  Downloading Flask_Cors-3.0.3-py2.py3-none-any.whl\r\nCollecting idna==2.6 (from -r /app/requirements.txt (line 6))\r\n  Downloading idna-2.6-py2.py3-none-any.whl (56kB)\r\nRequirement already satisfied: itsdangerous==0.24 in /usr/local/lib/python3.6/site-packages (from -r /app/requirements.txt (line 7))\r\nRequirement already satisfied: Jinja2==2.9.6 in /usr/local/lib/python3.6/site-packages (from -r /app/requirements.txt (line 8))\r\nRequirement already satisfied: MarkupSafe==1.0 in /usr/local/lib/python3.6/site-packages (from -r /app/requirements.txt (line 9))\r\nCollecting requests==2.18.4 (from -r /app/requirements.txt (line 10))\r\n  Downloading requests-2.18.4-py2.py3-none-any.whl (88kB)\r\nCollecting six==1.11.0 (from -r /app/requirements.txt (line 11))\r\n  Downloading six-1.11.0-py2.py3-none-any.whl\r\nCollecting urllib3==1.22 (from -r /app/requirements.txt (line 12))\r\n  Downloading urllib3-1.22-py2.py3-none-any.whl (132kB)\r\nRequirement already satisfied: Werkzeug==0.12.2 in /usr/local/lib/python3.6/site-packages (from -r /app/requirements.txt (line 13))\r\nInstalling collected packages: certifi, chardet, six, Flask-Cors, idna, urllib3, requests\r\nSuccessfully installed Flask-Cors-3.0.3 certifi-2017.7.27.1 chardet-3.0.4 idna-2.6 requests-2.18.4 six-1.11.0 urllib3-1.22\r\n ---> 0437821ea780\r\nRemoving intermediate container 85413afc84ee\r\nStep 5/5 : COPY . /app\r\n ---> aed7dfd1c4a8\r\nRemoving intermediate container debc2010ff97\r\nSuccessfully built aed7dfd1c4a8\r\nSuccessfully tagged app_web:latest\r\n```\r\n\r\nCan anyone see what I'm doing wrong here? Thank you!"},"comment":{"url":"https://api.github.com/repos/tiangolo/uwsgi-nginx-flask-docker/issues/comments/332326935","html_url":"https://github.com/tiangolo/uwsgi-nginx-flask-docker/issues/22#issuecomment-332326935","issue_url":"https://api.github.com/repos/tiangolo/uwsgi-nginx-flask-docker/issues/22","id":332326935,"user":{"login":"raddevon","id":2027711,"avatar_url":"https://avatars2.githubusercontent.com/u/2027711?v=4","gravatar_id":"","url":"https://api.github.com/users/raddevon","html_url":"https://github.com/raddevon","followers_url":"https://api.github.com/users/raddevon/followers","following_url":"https://api.github.com/users/raddevon/following{/other_user}","gists_url":"https://api.github.com/users/raddevon/gists{/gist_id}","starred_url":"https://api.github.com/users/raddevon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raddevon/subscriptions","organizations_url":"https://api.github.com/users/raddevon/orgs","repos_url":"https://api.github.com/users/raddevon/repos","events_url":"https://api.github.com/users/raddevon/events{/privacy}","received_events_url":"https://api.github.com/users/raddevon/received_events","type":"User","site_admin":false},"created_at":"2017-09-26T20:33:36Z","updated_at":"2017-09-26T20:33:36Z","author_association":"NONE","body":"Thank you for your help, @tiangolo!\r\n\r\nHere's the full output from starting the container:\r\n```\r\nCreating network \"gsawstestsuite_default\" with the default driver\r\nCreating gs-aws-test-suite-management ...\r\nCreating gs-aws-test-suite-management ... done\r\nAttaching to gs-aws-test-suite-management\r\ngs-aws-test-suite-management | /usr/lib/python2.7/dist-packages/supervisor/options.py:296: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a \"-c\" argument specifying an absolute path to a configuration file for improved security.\r\ngs-aws-test-suite-management |   'Supervisord is running as root and it is searching '\r\ngs-aws-test-suite-management | 2017-09-26 13:51:12,413 CRIT Supervisor running as root (no user in config file)\r\ngs-aws-test-suite-management | 2017-09-26 13:51:12,413 WARN Included extra file \"/etc/supervisor/conf.d/supervisord.conf\" during parsing\r\ngs-aws-test-suite-management | 2017-09-26 13:51:12,419 INFO RPC interface 'supervisor' initialized\r\ngs-aws-test-suite-management | 2017-09-26 13:51:12,419 CRIT Server 'unix_http_server' running without any HTTP authentication checking\r\ngs-aws-test-suite-management | 2017-09-26 13:51:12,419 INFO supervisord started with pid 1\r\ngs-aws-test-suite-management | 2017-09-26 13:51:13,425 INFO spawned: 'nginx' with pid 9\r\ngs-aws-test-suite-management | 2017-09-26 13:51:13,427 INFO spawned: 'uwsgi' with pid 10\r\ngs-aws-test-suite-management | [uWSGI] getting INI configuration from /app/uwsgi.ini\r\ngs-aws-test-suite-management | [uWSGI] getting INI configuration from /etc/uwsgi/uwsgi.ini\r\ngs-aws-test-suite-management | *** Starting uWSGI 2.0.15 (64bit) on [Tue Sep 26 13:51:13 2017] ***\r\ngs-aws-test-suite-management | compiled with version: 4.9.2 on 10 August 2017 16:32:21\r\ngs-aws-test-suite-management | os: Linux-4.9.41-moby #1 SMP Wed Sep 6 00:05:16 UTC 2017\r\ngs-aws-test-suite-management | nodename: 953267145d0f\r\ngs-aws-test-suite-management | machine: x86_64\r\ngs-aws-test-suite-management | clock source: unix\r\ngs-aws-test-suite-management | pcre jit disabled\r\ngs-aws-test-suite-management | detected number of CPU cores: 4\r\ngs-aws-test-suite-management | current working directory: /app\r\ngs-aws-test-suite-management | detected binary path: /usr/local/bin/uwsgi\r\ngs-aws-test-suite-management | your memory page size is 4096 bytes\r\ngs-aws-test-suite-management | detected max file descriptor number: 1048576\r\ngs-aws-test-suite-management | lock engine: pthread robust mutexes\r\ngs-aws-test-suite-management | thunder lock: disabled (you can enable it with --thunder-lock)\r\ngs-aws-test-suite-management | uwsgi socket 0 bound to UNIX address /tmp/uwsgi.sock fd 3\r\ngs-aws-test-suite-management | uWSGI running as root, you can use --uid/--gid/--chroot options\r\ngs-aws-test-suite-management | *** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***\r\ngs-aws-test-suite-management | Python version: 3.6.2 (default, Jul 24 2017, 19:47:39)  [GCC 4.9.2]\r\ngs-aws-test-suite-management | *** Python threads support is disabled. You can enable it with --enable-threads ***\r\ngs-aws-test-suite-management | Python main interpreter initialized at 0x245bf40\r\ngs-aws-test-suite-management | your server socket listen backlog is limited to 100 connections\r\ngs-aws-test-suite-management | your mercy for graceful operations on workers is 60 seconds\r\ngs-aws-test-suite-management | mapped 1237056 bytes (1208 KB) for 16 cores\r\ngs-aws-test-suite-management | *** Operational MODE: preforking ***\r\ngs-aws-test-suite-management | Traceback (most recent call last):\r\ngs-aws-test-suite-management |   File \"./main.py\", line 4, in <module>\r\ngs-aws-test-suite-management |     from flask_cors import CORS\r\ngs-aws-test-suite-management | ModuleNotFoundError: No module named 'flask_cors'\r\ngs-aws-test-suite-management | unable to load app 0 (mountpoint='') (callable not found or import error)\r\ngs-aws-test-suite-management | *** no app loaded. going in full dynamic mode ***\r\ngs-aws-test-suite-management | *** uWSGI is running in multiple interpreter mode ***\r\ngs-aws-test-suite-management | spawned uWSGI master process (pid: 10)\r\ngs-aws-test-suite-management | spawned uWSGI worker 1 (pid: 13, cores: 1)\r\ngs-aws-test-suite-management | spawned uWSGI worker 2 (pid: 14, cores: 1)\r\ngs-aws-test-suite-management | 2017-09-26 13:51:14,735 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)\r\ngs-aws-test-suite-management | 2017-09-26 13:51:14,735 INFO success: uwsgi entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)\r\n```\r\n\r\n`ModuleNotFoundError: No module named 'flask_cors'` is probably the part you needed.\r\n\r\nYou're right it was using the cache, but that's because I had already built it once previously. I believe the requirements.txt was already current in the cache. In either case, I *do* think it successfully installed Flask-Cors (the module the app is failing to import) because of the output from the `pip install` step of the build.\r\n```\r\n…\r\nSuccessfully installed Flask-Cors-3.0.3...\r\n…\r\n```\r\n\r\nI updated the Dockerfile to install the packages explicitly instead of installing from `requirements.txt`, but the app is still fails to start because it can't find the `flask_cors` module. Here's my current Dockerfile:\r\n```\r\nFROM tiangolo/uwsgi-nginx-flask:python3.6\r\n\r\nENV STATIC_INDEX 1\r\n\r\n# COPY requirements.txt /app/\r\n# RUN pip install -r /app/requirements.txt\r\nRUN pip install Flask-Cors\r\nRUN pip install requests\r\n\r\nCOPY . /app\r\n```\r\n\r\nand here's the relevant bit of the output of the bringing the container up with a few extra lines on either side for context:\r\n```\r\ngs-aws-test-suite-management | Python version: 3.6.2 (default, Jul 24 2017, 19:47:39)  [GCC 4.9.2]\r\ngs-aws-test-suite-management | *** Python threads support is disabled. You can enable it with --enable-threads ***\r\ngs-aws-test-suite-management | Python main interpreter initialized at 0xc80f40\r\ngs-aws-test-suite-management | your server socket listen backlog is limited to 100 connections\r\ngs-aws-test-suite-management | your mercy for graceful operations on workers is 60 seconds\r\ngs-aws-test-suite-management | mapped 1237056 bytes (1208 KB) for 16 cores\r\ngs-aws-test-suite-management | *** Operational MODE: preforking ***\r\ngs-aws-test-suite-management | Traceback (most recent call last):\r\ngs-aws-test-suite-management |   File \"./main.py\", line 4, in <module>\r\ngs-aws-test-suite-management |     from flask_cors import CORS\r\ngs-aws-test-suite-management | ModuleNotFoundError: No module named 'flask_cors'\r\ngs-aws-test-suite-management | unable to load app 0 (mountpoint='') (callable not found or import error)\r\ngs-aws-test-suite-management | *** no app loaded. going in full dynamic mode ***\r\ngs-aws-test-suite-management | *** uWSGI is running in multiple interpreter mode ***\r\n```"}}
{"actor":{"display_login":"raddevon"}}