I'm trying to deploy a django project with Elastic Beanstalk cli. I followed the Official Amazon Tutorial as well as this Tutorial on realpython.com.
The Deploymentprocess works fine as long as I stick to a newly created Django Project with just a view dependencies for pip.
When try it with my Django Project The Deployment fails because the requirements.txt is invalid. I created it inside my virutalenv like this: pip freeze > requirements.txt
braintree==3.32.0
cffi==1.9.1
cryptography==1.7
Django==1.10.4
django-allauth==0.29.0
django-betterforms==1.1.4
django-contrib-comments==1.7.3
django-formtools==1.0
django-payments==0.9.6
django-tinymce==2.4.0
enum34==1.1.6
idna==2.1
ipaddress==1.0.17
oauthlib==2.0.1
Pillow==3.4.2
pyasn1==0.1.9
pycparser==2.17
PyJWT==1.4.2
python-openid==2.2.5
requests==2.12.3
requests-oauthlib==0.7.0
six==1.10.0
stripe==1.43.0
suds-jurko==0.6
xmltodict==0.10.2
In my despair I tried to activate the dependencies one by one. The Deployment process is so slow that I gave up after a while. But now I know now that Django==1.10.4, django-allauth==0.29.0, django-betterforms==1.1.4, django-contrib-comments==1.7.3, django-formtools==1.0 and django-tinymce==2.4.0 are not the problem. With django-payments==0.9.6 it fails but its not the only dependency that causes the problem.
This is in my activity.log:
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/opt/python/run/venv/bin/python2.7 -c "import setuptools, tokenize;
__file__='/tmp/pip-build-BF9Oen/cffi/setup.py';
exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))"
install --record /tmp/pip-BsXWzo-record/install-record.txt --single-version-externally-managed --compile --install-headers
/opt/python/run/venv/include/site/python2.7/cffi" failed with error code 1 in /tmp/pip-build-BF9Oen/cffi
You are using pip version 7.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
2016-12-13 14:49:05,155 ERROR
Error installing dependencies: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1
Traceback (most recent call last):
File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 22, in main
install_dependencies()
File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 18, in install_dependencies
check_call('%s install -r %s' % (os.path.join(APP_VIRTUAL_ENV, 'bin', 'pip'), requirements_file), shell=True)
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 (Executor::NonZeroExitStatus)
I't could have something to do with missing Software. I know how to use the .ebextensions .config files but I don't know whats missing. Is there a descent way to debug this locally?
You seem to have problems with both FFI and Python. You have Cryptography in use but don't probably have all the required libraries Install Python and FFI requirements and OpenSSL dependencies for Cryptography.
$ eb ssh # SSH into your EB environment
$ sudo su # gain root privileges
$ yum install python-devel # or python27-devel
$ yum install libffi-devel # CFFI / FFI requirements
$ yum install openssl-devel # Cryptography requirements
If Pip complains, make sure you have the latest pip installed:
# repeat SSH and root privilege steps
$ source /opt/python/run/venv/bin/activate # activate Python environment
$ pip install --upgrade pip # upgrade to latest pip
To make the changes permanent, append them to your EB configuration. This also works if you do not have direct SSH access.
# .ebextensions/10_packages.config excerpt
packages:
yum:
gcc: []
libffi-devel: []
openssl-devel: []
python-devel: [] # or python27-devel
.ebextensions folder files with the .config suffix are state declarations for the Elastic Beanstalk environment. That is, they are instructions that are run on each Elastic Beanstalk deployment when you run eb deploy or your CI environment deploys code to EB.
Amazon Linux is an RPM based Linux that uses YUM for package management. You will find RHEL / CentOS / OpenSUSE instructions for Python package installation helpful for the Amazon Linux distribution.
There typically isn’t a way to debug these issues locally, because people don’t normally run Amazon linux on their local machines, and EB has a very specific environment setup that is not easy to reproduce (at least it wasn’t for me).
If you want to do it fast, just ssh to one of your EB/EC2 instances and try to install the pip requirements one-by-one by hand. If you want to do it right, you do have to go through this list of requirements one-by-one. (i.e., start with one requirement in the requirements file, deploy, then two requirements, then three requirements, etc.). You may want to start with upgrading pip by adding
pip==9.0.1
At the top of your requirements file and also making sure the following Amazon Linux (if that is what you are using) are installed:
python-devel
libffi
libffi-devel
Related
I've installed flask, flask_login, and ldap in the virtualenv for my flask package (to authenticate ldap users with the usernames & passwords of the other users at my company).
When I run my flask app, I get "AttributeError: 'module' object has no attribute 'initialize'"
I'm tried "pip install python-ldap"
but I get a red error (sandwiched between other white text) that reads:
"Failed building wheel for python-ldap"
I have thoroughly examined these:
How to install python-ldap on a python 2.7 virtualenv on windows without compiling
Installing python-ldap in a virtualenv on Windows
https://www.python-ldap.org/docs.html
https://www.linuxjournal.com/article/6988?page=0,1
to no avail.
I've had this error for days now...
(also:
pip install openldap
gives:
Collecting openldap
Could not find a version that satisfies the requirement openldap (from versions: )
No matching distribution found for openldap
...(in and outside of my venv) if that information helps)
I had this error last week and after switching work computers, I recreated the virtualenv and installed all of the other packages and dependencies successfully.
my requirements.txt file contains these lines after a line of git stuff:
click==6.7
Flask==0.12.2
Flask-Login==0.4.0
itsdangerous==0.24
Jinja2==2.9.6
ldap==1.0.2
ldap3==2.2.4
MarkupSafe==1.0
pyasn1==0.2.3
Werkzeug==0.12.2
Has anyone successfully installed python-ldap into a flask virtualenv with windows? If so... how?!
Go to:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap
download python_ldap-2.4.38-cp27-cp27m-win_amd64.whl in the same directory that your venv folder is listed under
(ex.)
/myrepo
/myapp
/myapp
/venv
/run.py
/python_ldap-2.4.38-cp27-cp27m-win_amd64.whl
install the .whl file while inside of your venv
venv\Scripts\activate
pip install python_ldap-2.4.38-cp27-cp27m-win_amd64.whl
Voila!
The error
ERROR: Failed building wheel for python-ldap
can occur for several reasons. You actually have to look at what happened above this line. In my case, I just had to install missing dependencies to build python-ldap. You can look them up here. For CentOS 8, I had to install:
sudo dnf install openldap-devel python3-devel gcc
to make
python3 -m pip install --user python-ldap -U
work.
I unpacked the presto on AWS EC2 instance and followed the documentation on prestodb
when I run bin/launcher startI get the following error:
/usr/bin/env: ‘python’: No such file or directory
I guess documentation could mention that explicitly, but you need certain piece of software installed to run presto. This includes, but is not limited to:
Supported Java JVM
Python (i guess 2.7 would do)
For Ubuntu/Debian:
Install Python if you did not do before:
apt-get install python3
If you have python already:
whereis python3
sudo ln -s /usr/bin/python3 /usr/bin/pytho
I am trying to make an ebextensions file which will install wkhtmltopdf.
Currently it looks like this:
packages:
yum:
xorg-x11-fonts-75dpi: []
libpng: []
xz: []
urw-fonts: []
libXext: []
openssl-devel: []
libXrender: []
rpm:
wkhtmltopdf: https://s3-eu-west-1.amazonaws.com/myS3Account/wkhtmltox-0.12.2.1_linux-centos5-amd64.rpm
In this case, wkthmltopdf fails to install. I get the following error:
Failed dependencies:
xorg-x11-fonts-75dpi is needed by wkhtmltox-1:0.12.2.1-1.x86_64
If I use SSH to connect to my EC2 instance, I can sucessfully install wkhtml by manually running "yum install xorg-x11-fonts-75dpi", followed by "wget wkthmltopdf-..." and "rpm --install wkhtmltopdf-..". If I skip the yum step, rpm complains that wkhtmltopdf needs the xorg package.
It seems like xorg-x11-fonts-75dpi is not installed by ebextensions on deploy. Am I doing something wrong?
According to the docs:
Packages are processed in the following order: rpm, yum, and then rubygems and python.
Elastic beanstalk first processes your rpm package, causing the error and never gets to the yum packages.
There are a few ways to solve this.
1) Run the rpm install through a command like
commands:
install_wkhtmltox:
command: yum -y install https://s3-eu-west-1.amazonaws.com/myS3Account/wkhtmltox-0.12.2.1_linux-centos5-amd64.rpm
This should automatically solve dependencies through yum.
2) Split the .ebextensions files to two: 01_install_dependencies.config and 02_install_wkhtmltox.config. In the 01-file install yum packages, in the 02 file install the rpm. This way you can "override" the package installation order
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-packages
I'm trying to install the peewee package on an elastic beanstalk instance to control a bottle application. I think the problem is with the MySQL-python dependency, but peewee doesn't load either. My requirements file looks like this:
bottle==0.11.6
peewee==2.1.1
MySQL-python
I also tried MySQL-python as MySQL-python==1.2.4b4. For a number of reasons which I believe are summed up here, this doesn't work; peewee isn't installed and I get this error message in the log:
2013-05-18 06:57:08,407 [INFO] (15947 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Script succeeded.
2013-05-18 06:57:08,408 [INFO] (15947 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Executing script: /opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py
2013-05-18 06:57:18,663 [INFO] (15947 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Output from script: New python executable in /opt/python/run/venv/bin/python2.6
Not overwriting existing python script /opt/python/run/venv/bin/python (you must use /opt/python/run/venv/bin/python2.6)
Installing distribute..................................................................................................................................................................................................done.
Installing pip................done.
Requirement already satisfied (use --upgrade to upgrade): bottle==0.11.6 in /opt/python/run/venv/lib/python2.6/site-packages (from -r /opt/python/ondeck/app/requirements.txt (line 1))
Downloading/unpacking peewee==2.1.1 (from -r /opt/python/ondeck/app/requirements.txt (line 2))
Running setup.py egg_info for package peewee
Downloading/unpacking MySQL-python (from -r /opt/python/ondeck/app/requirements.txt (line 3))
Running setup.py egg_info for package MySQL-python
The required version of distribute (>=0.6.28) is not available,
and can't be installed while this script is running. Please
install a more recent version first, using
'easy_install -U distribute'.
(Currently using distribute 0.6.27 (/opt/python/run/venv/lib/python2.6/site-packages/distribute-0.6.27-py2.6.egg))
Complete output from command python setup.py egg_info:
The required version of distribute (>=0.6.28) is not available,
and can't be installed while this script is running. Please
install a more recent version first, using
'easy_install -U distribute'.
So pip doesn't work for these packages. I'm pretty sure I could fix this by connecting to the EC2 instance and installing MySQL-python without pip, but it seems to me that would defeat the purpose of elastic beanstalk, since every time a new instance started it would need me to go in and tinker with it manually. Is there a proper way for me to deal with this problem? I've also had the same issue trying to install things like scipy and matplotlib, so broadly, is there a way I can install python packages on elastic beanstalk instances without pip, and without going into each instance individually? Should I be looking into how to make a custom AMI and use it on beanstalk?
Thanks a lot,
Alex
Sorry I forgot I asked this.
I eventually solved this issue by ssh'ing into the instance and installing MySQL-Python using easy_install instead of pip.
Basically I went to the python virtual environment direction at:
opt/python/run/venv/bin
and installed version 1.2.3 using easy_install:
sudo ./easy_install MySQL-Python==1.2.3
I checked to see it was installed by trying to import MySQLdb in the virtual environment's python:
./python
>>>import MySQLdb
>>>
and it worked for me. Then I reset the server by pushing to it again with the elastic beanstalk command line tool:
git aws.push
and that's about it. Somewhat annoying to have to do it, but it seems to continue to work when a new instance is started up.
Thanks,
Alex
I am trying to run a python tool that will authenticate me to linkedin, in order for me to download my linkedin network so that I might be able to analyze it inside of Gephi. I obtained such a file here:
linkedin-1-oauth.py from github
I cloned that and the two other files he has in the gist. I did this from my terminal by just doing git clone [url here] for all 3 of the files. I put my api and secret keys in the corresponding places.
I did a pip install oauth2 and updated httplib2 as suggested here:
pip install oauth2 and update httplib2
I also did this from the command line, which downloaded and installed the files in the same directory as to where I downloaded the linkedin files from gist, just all in my user folder.
When trying pip install oauth2 and get the following error message:
Downloading/unpacking oauth2
Running setup.py egg_info for package oauth2
Requirement already satisfied (use --upgrade to upgrade): httplib2 in /usr/lib/python2.7/dist-packages (from oauth2)
Installing collected packages: oauth2
Running setup.py install for oauth2
error: could not create '/usr/local/lib/python2.7/dist-packages/oauth2': Permission denied
Complete output from command /usr/bin/python -c "import setuptools;__file__='/home/steven/build/oauth2/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-e2RkcV-record/install-record.txt:
running install
running build
running build_py
running install_lib
creating /usr/local/lib/python2.7/dist-packages/oauth2
error: could not create '/usr/local/lib/python2.7/dist-packages/oauth2': Permission denied
----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/home/steven/build/oauth2/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-e2RkcV-record/install-record.txt failed with error code 1
Storing complete log in /home/steven/.pip/pip.log
I then tried easy_install oauth2 and got the following error message:
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/test-easy-install-4349.pth'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/usr/local/lib/python2.7/dist-packages/
Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.
For information on other options, you may wish to consult the
documentation at:
http://packages.python.org/distribute/easy_install.html
Please make the appropriate changes for your system and try again.
So then I tried doing sudo apt-get install oauth2 and it could not be found
I am running Ubuntu 12.04 LTS I did all my sudo update and upgrades before I did anything else this morning. I am running python 2.7
Thank you
I was able to fix the problem by going here:
python-oauth2
Steps to install python oauth2 library on windows
Download http://python-distribute.org/distribute_setup.py and copy wherever python was installed
Run "python distribute_setup.py"
Download and unzip Oauth2 to a directory. Navigate to this directory.
Run "python setup.py install" to install ouath2
if you have python 2.7.10 or higher here is simpler method.
Use 'pip' to install python modules.
Say in my case on windows following does the trick.
C:\Python27\Scripts\pip install ouath2