Last time I tried this, I ended up semi-deliberately choosing to use Python 3 for a tutorial (I didn’t realize quickly enough) was built around Python 2.
After cleaning up my experiment I remembered that the default python on my MacBook was still python 2.7.10, which gave me the idea I might be able to re-run that tutorial with all-Python 2 dependencies. Or so it seemed.
Strangely, the first step both went better and no better than last time:
Mac4Mike:flask-aws-tutorial mike$ virtualenv flask-aws Using base prefix '/usr/local/Cellar/python3/3.5.2_3/Frameworks/Python.framework/Versions/3.5' New python executable in /Users/mike/code/flask-aws-tutorial/flask-aws/bin/python3.5 Also creating executable in /Users/mike/code/flask-aws-tutorial/flask-aws/bin/python Installing setuptools, pip, wheel...done.
Yes it didn’t throw any errors, but no it didn’t use the base Python 2 that I’d hoped. Somehow the fact that I’ve installed Python 3 on my system is still getting picked up by virtualenv, so I needed to dig further into how virtualenv can be used to truly insulate from Python 3.
Found a decent article here that gave me hope, and even though they punted to using the virtualenvwrapper scripts, it still clued me in to the virtualenv parameter “-p”, so this seemed to work like a charm:
Mac4Mike:flask-aws-tutorial mike$ virtualenv flask-aws -p /usr/bin/python Running virtualenv with interpreter /usr/bin/python New python executable in /Users/mike/code/flask-aws-tutorial/flask-aws/bin/python Installing setuptools, pip, wheel...done.
This time? The requirements install worked like a charm:
Successfully installed Flask-0.10.1 Flask-SQLAlchemy-2.0 Flask-WTF-0.10.3 Jinja2-2.7.3 MarkupSafe-0.23 PyMySQL-0.6.3 SQLAlchemy-0.9.8 WTForms-2.0.1 Werkzeug-0.9.6 argparse-1.2.1 boto-2.28.0 itsdangerous-0.24 newrelic-188.8.131.52
Then (since I still had all the config in place), I ran pip install awsebcli and skipped all the way to the bottom of the tutorial and tried eb deploy:
INFO: Deploying new version to instance(s). ERROR: Your requirements.txt is invalid. Snapshot your logs for details. ERROR: [Instance: i-01b45c4d01c070555] Command failed on instance. Return code: 1 Output: (TRUNCATED)...) File "/usr/lib64/python2.7/subprocess.py", line 541, in check_call raise CalledProcessError(retcode, cmd) CalledProcessError: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1. Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py failed. For more detail, check /var/log/eb-activity.log using console or EB CLI. INFO: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1]. ERROR: Unsuccessful command execution on instance id(s) 'i-01b45c4d01c070555'. Aborting the operation. ERROR: Failed to deploy application.
This kept barfing over and over until I remembered that the target environment was still configured for Python 3.4. Fortunately or not, you can’t change major versions of the platform – so back to eb init I go (with the -i parameter to re-initialize).
This time around? The command eb deploy worked like a charm.
Lesson: be *very* explicit about your Python versions when messing with someone else’s code. [Duh.]