I am trying to get Django-Weasyprint working correctly on an AWS Linux2 Elastic Beanstalk instance. I have come across [this question][1] and when I add the code to .platform/hooks/predeploy the images all work but the href links stop working.
I have, therefore, tried to upgrade the packages within the script and my script now looks like:
#!/usr/bin/env bash
yum install -y libxml2-devel libxslt-devel python-devel redhat-rpm-config libffi-devel cairo pango
export PKG_CONFIG_PATH=/usr/lib64/pkgconfig:/usr/lib/pkgconfig
export PATH=/usr/bin:$PATH
export LDFLAGS=-L/usr/lib64:/usr/lib
export LD_LIBRARY_PATH=/usr/lib64:/usr/lib
export CPPFLAGS=-I/usr/include
sudo yum-config-manager --enable epel
sudo yum update -y
sudo yum install -y gcc gcc-c++ glib2-devel.x86_64 libxml2-devel.x86_64 libpng-devel.x86_64 \
libjpeg-turbo-devel.x86_64 gobject-introspection.x86_64 gobject-introspection-devel.x86_64
wget http://ftp.gnome.org/pub/GNOME/sources/libcroco/0.6/libcroco-0.6.13.tar.xz
tar xvfJ libcroco-0.6.13.tar.xz
cd libcroco-0.6.13
./configure --prefix=/usr
make
sudo make install
cd ..
wget http://ftp.gnome.org/pub/GNOME/sources/gdk-pixbuf/2.42/gdk-pixbuf-2.42.6.tar.xz
tar xvfJ gdk-pixbuf-2.42.6.tar.xz
cd gdk-pixbuf-2.42.6
./configure --prefix=/usr --without-libtiff
make
sudo make install
cd ..
sudo yum install -y pixman-devel.x86_64 harfbuzz-devel.x86_64 freetype-devel.x86_64
wget http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.13.93.tar.gz
tar xvf fontconfig-2.13.93.tar.gz
cd fontconfig-2.13.93
./configure --prefix=/usr --enable-libxml2
make
sudo make install
cd ..
wget http://cairographics.org/releases/cairo-1.16.0.tar.xz
tar xvfJ cairo-1.16.0.tar.xz
cd cairo-1.16.0
./configure --prefix=/usr
make
sudo make install
cd ..
wget http://ftp.gnome.org/pub/GNOME/sources/pango/1.48/pango-1.48.4.tar.xz
tar xvfJ pango-1.48.4.tar.xz
cd pango-1.48.4
./configure --prefix=/usr
make
sudo make install
cd ..
wget http://ftp.gnome.org/pub/GNOME/sources/librsvg/2.50/librsvg-2.50.5.tar.xz
tar xvfJ librsvg-2.50.5.tar.xz
cd librsvg-2.50.5
./configure --prefix=/usr
make
sudo make install
cd ..
sudo ldconfig /usr/lib
It generates the following error:
OSError: cannot load library 'libpangocairo-1.0.so.0':
/lib64/libpangoft2-1.0.so.0: undefined symbol:
FcWeightFromOpenTypeDouble
I don't know how to resolve and would appreciate some help - thanks
[1]: Django Weasyprint on Elastic Beanstalk - Could not load GDK-Pixbuf
For me the solution was to put the following 01_weasyprint.sh file in hooks > predeploy > 01_weasyprint.sh
#!/usr/bin/env bash
yum install -y libxml2-devel libxslt-devel python-devel redhat-rpm-config libffi-devel cairo pango
export PKG_CONFIG_PATH=/usr/lib64/pkgconfig:/usr/lib/pkgconfig
export PATH=/usr/bin:$PATH
export LDFLAGS=-L/usr/lib64:/usr/lib
export LD_LIBRARY_PATH=/usr/lib64:/usr/lib
export CPPFLAGS=-I/usr/include
sudo yum-config-manager --enable epel
sudo yum update -y
sudo yum install -y gcc gcc-c++ glib2-devel.x86_64 libxml2-devel.x86_64 libpng-devel.x86_64 \
libjpeg-turbo-devel.x86_64 gobject-introspection.x86_64 gobject-introspection-devel.x86_64
wget http://ftp.gnome.org/pub/GNOME/sources/libcroco/0.6/libcroco-0.6.8.tar.xz
tar xvfJ libcroco-0.6.8.tar.xz
cd libcroco-0.6.8
./configure --prefix=/usr
make
sudo make install
cd ..
wget http://ftp.gnome.org/pub/GNOME/sources/gdk-pixbuf/2.28/gdk-pixbuf-2.28.2.tar.xz
tar xvfJ gdk-pixbuf-2.28.2.tar.xz
cd gdk-pixbuf-2.28.2
./configure --prefix=/usr --without-libtiff
make
sudo make install
cd ..
sudo yum install -y pixman-devel.x86_64 harfbuzz-devel.x86_64 freetype-devel.x86_64
wget http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.13.93.tar.gz
tar xvf fontconfig-2.13.93.tar.gz
cd fontconfig-2.13.93
./configure --prefix=/usr --enable-libxml2
make
sudo make install
cd ..
wget http://cairographics.org/releases/cairo-1.16.0.tar.xz
tar xvfJ cairo-1.16.0.tar.xz
cd cairo-1.16.0
./configure --prefix=/usr
make
sudo make install
cd ..
wget http://ftp.gnome.org/pub/GNOME/sources/pango/1.48/pango-1.48.4.tar.xz
tar xvfJ pango-1.48.4.tar.xz
cd pango-1.48.4
./configure --prefix=/usr
make
sudo make install
cd ..
wget http://ftp.gnome.org/pub/GNOME/sources/librsvg/2.40/librsvg-2.40.6.tar.xz
tar xvfJ librsvg-2.40.6.tar.xz
cd librsvg-2.40.6
./configure --prefix=/usr
make
sudo make install
cd ..
sudo ldconfig /usr/lib
Related
what are the correct steps to install geodjango on elastic beanstalk?
got eb instance, installed env and made it two instances now I want to use geodjango on it, I'm already using it on a separate ec2 instance for testing
that's my django.config file and it fails
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: hike.project.wsgi:application
commands:
01_gdal:
command: "wget http://download.osgeo.org/gdal/2.1.3/gdal-2.1.3.tar.gz && tar -xzf gdal-2.1.3.tar.gz && cd gdal-2.1.3 && ./configure && make && make install"
then tried this instead and also failed from 100% cpu and time limit
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: hike.project.wsgi:application
commands:
01_install_gdal:
test: "[ ! -d /usr/local/gdal ]"
command: "/tmp/gdal_install.sh"
files:
"/tmp/gdal_install.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
sudo yum-config-manager --enable epel
sudo yum -y install make automake gcc gcc-c++ libcurl-devel proj-devel geos-devel
# Geos
cd /
sudo mkdir -p /usr/local/geos
cd usr/local/geos/geos-3.7.2
sudo wget geos-3.7.2.tar.bz2 http://download.osgeo.org/geos/geos-3.7.2.tar.bz2
sudo tar -xvf geos-3.7.2.tar.bz2
cd geos-3.7.2
sudo ./configure
sudo make
sudo make install
sudo ldconfig
# Proj4
cd /
sudo mkdir -p /usr/local/proj
cd usr/local/proj
sudo wget -O proj-5.2.0.tar.gz http://download.osgeo.org/proj/proj-5.2.0.tar.gz
sudo wget -O proj-datumgrid-1.8.tar.gz http://download.osgeo.org/proj/proj-datumgrid-1.8.tar.gz
sudo tar xvf proj-5.2.0.tar.gz
sudo tar xvf proj-datumgrid-1.8.tar.gz
cd proj-5.2.0
sudo ./configure
sudo make
sudo make install
sudo ldconfig
# GDAL
cd /
sudo mkdir -p /usr/local/gdal
cd usr/local/gdal
sudo wget -O gdal-2.4.4.tar.gz http://download.osgeo.org/gdal/2.4.4/gdal-2.4.4.tar.gz
sudo tar xvf gdal-2.4.4.tar.gz
cd gdal-2.4.4
sudo ./configure
sudo make
sudo make install
sudo ldconfig
and I've no idea what to do,
I am trying to install a number of dependencies for my jupyter notebook, but would like them to be permanent to save me 20 minutes every time I restart the notebook. I have opted for using a lifecycle configuration, however, my script takes longer than 5 minutes to run. I found this article (https://aws.amazon.com/premiumsupport/knowledge-center/sagemaker-lifecycle-script-timeout/) to help resolve this problem, however, my notebook is still failing to start with the following error:
Notebook Instance Lifecycle Config 'arn:aws:sagemaker:eu-west-2:347285168835:notebook-instance-lifecycle-config/nbs-aap-dev-dsar' for Notebook Instance 'arn:aws:sagemaker:eu-west-2:347285168835:notebook-instance/nbs-aap-dev-dsar' took longer than 5 minutes. Please check your CloudWatch logs for more details if your Notebook Instance has Internet access.
Here is the script I am trying to run:
sudo nohup yum install wget &
sudo yum install autoconf &
sudo yum install automake &
sudo yum install libtool &
sudo yum install jpeg &
sudo yum install tiff &
sudo yum install libpng &
sudo yum install tiff2png &
sudo yum install libtiff &
sudo yum install autoconf aclocal automake &
sudo yum install libtool &
sudo yum -y install libjpeg-devel libpng-devel libpng-devel libtiff-devel zlib-devel &
sudo yum install gcc gcc-c++ make &
sudo wget https://github.com/DanBloomberg/leptonica/releases/download/1.82.0/leptonica-1.82.0.tar.gz &
sudo tar xzvf leptonica-1.82.0.tar.gz &
cd leptonica-1.82.0 &
sudo ./configure --prefix=/usr/local/ &
sudo make &
sudo make install &
sudo wget https://codeload.github.com/tesseract-ocr/tesseract/tar.gz/4.1.1 &
sudo tar -zxvf 4.1.1 &
cd tesseract-4.1.1 &
sudo ./autogen.sh &
sudo cp /home/ec2-user/leptonica-1.82.0/lept.pc /usr/lib64/pkgconfig/. &
sudo LIBLEPT_HEADERSDIR=/usr/local/lib ./configure --prefix=/usr/local/ --with-extra-libraries=/usr/local/lib &
sudo make &
sudo make install &
export LD_LIBRARY_PATH=/usr/local/lib &
sudo ldconfig &
sudo wget https://github.com/tesseract-ocr/tessdata_best/raw/main/eng.traineddata &
sudo mv -v eng.traineddata /usr/local/share/tessdata/eng.traineddata &
sudo wget https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs9550/ghostpdl-9.55.0.tar.gz &
sudo tar -zxvf ghostpdl-9.55.0.tar.gz &
cd ghostpdl-9.55.0 &
sudo ./configure --prefix=/usr/local/ &
sudo make &
sudo make install &
sudo yum -y install poppler-utils &
sudo wget https://github.com/qpdf/qpdf/releases/download/release-qpdf-10.1.0/qpdf-10.1.0.tar.gz &
sudo tar xzvf qpdf-10.1.0.tar.gz &
cd qpdf-10.1.0 &
sudo ./configure --prefix=/usr/local/ &
sudo make &
sudo make install
You do not need to add ampersand & on the end of the lines. This put them in background and execute some commands in parallel which lead to odd conditions. For example in code:
sudo ./configure --prefix=/usr/local/ &
sudo make &
sudo make install &
the command make start before end of configure and will not end well in most of the cases. Same for make install it try to install the compiled package before it is compiled from make
If you want to put script in background you can group the commands on this way:
sudo nohup yum -y install wget autoconf automake libtool jpeg tiff libpng tiff2png libtiff autoconf aclocal automake libtool libjpeg-devel libpng-devel libpng-devel libtiff-devel zlib-devel gcc gcc-c++ make poppler-utils
nohup sudo wget https://github.com/DanBloomberg/leptonica/releases/download/1.82.0/leptonica-1.82.0.tar.gz && sudo tar xzvf leptonica-1.82.0.tar.gz &&cd leptonica-1.82.0 && sudo ./configure --prefix=/usr/local/ && sudo make && sudo make install &
nohup sudo wget https://codeload.github.com/tesseract-ocr/tesseract/tar.gz/4.1.1 &&sudo tar -zxvf 4.1.1 && cd tesseract-4.1.1 && sudo ./autogen.sh && sudo cp /home/ec2-user/leptonica-1.82.0/lept.pc /usr/lib64/pkgconfig/. && sudo LIBLEPT_HEADERSDIR=/usr/local/lib ./configure --prefix=/usr/local/ --with-extra-libraries=/usr/local/lib && sudo make && sudo make install &
nohup export LD_LIBRARY_PATH=/usr/local/lib && sudo ldconfig && sudo wget https://github.com/tesseract-ocr/tessdata_best/raw/main/eng.traineddata && sudo mv -v eng.traineddata /usr/local/share/tessdata/eng.traineddata && sudo wget https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs9550/ghostpdl-9.55.0.tar.gz && sudo tar -zxvf ghostpdl-9.55.0.tar.gz && cd ghostpdl-9.55.0 && sudo ./configure --prefix=/usr/local/ && sudo make && sudo make install &
nohup sudo wget https://github.com/qpdf/qpdf/releases/download/release-qpdf-10.1.0/qpdf-10.1.0.tar.gz && sudo tar xzvf qpdf-10.1.0.tar.gz && cd qpdf-10.1.0 && sudo ./configure --prefix=/usr/local/ && sudo make && sudo make install &
I'm trying to deploy a geodjango application on AWS Elastic Beanstalk. The configuration is 64bit Amazon Linux 2017.09 v2.6.6 running Python 3.6. I am getting this error when trying to deploy:
Requires: libpoppler.so.5()(64bit) Error: Package: gdal-java-1.9.2-8.rhel6.x86_64 (pgdg93) Requires: libpoppler.so.5()(64bit)
How do I install the required package? I read through Setting up Django with GeoDjango Support in AWS Beanstalk or EC2 Instance but I am still getting problems. My ebextensions currently looks like:
commands:
01_yum_update:
command: sudo yum -y update
02_epel_repo:
command: sudo yum-config-manager -y --enable epel
03_install_gdal_packages:
command: sudo yum -y install gdal gdal-devel
packages:
yum:
git: []
postgresql95-devel: []
gettext: []
libjpeg-turbo-devel: []
libffi-devel: []
I'm going to answer my own question for the sake my future projects and anyone else trying to get started with geodjango. Updating this answer as of July 2020
Create an ebextensions file to install GDAL on the EC2 instance at deployment:
01_gdal.config
commands:
01_install_gdal:
test: "[ ! -d /usr/local/gdal ]"
command: "/tmp/gdal_install.sh"
files:
"/tmp/gdal_install.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
sudo yum-config-manager --enable epel
sudo yum -y install make automake gcc gcc-c++ libcurl-devel proj-devel geos-devel
# Geos
cd /
sudo mkdir -p /usr/local/geos
cd usr/local/geos/geos-3.7.2
sudo wget geos-3.7.2.tar.bz2 http://download.osgeo.org/geos/geos-3.7.2.tar.bz2
sudo tar -xvf geos-3.7.2.tar.bz2
cd geos-3.7.2
sudo ./configure
sudo make
sudo make install
sudo ldconfig
# Proj4
cd /
sudo mkdir -p /usr/local/proj
cd usr/local/proj
sudo wget -O proj-5.2.0.tar.gz http://download.osgeo.org/proj/proj-5.2.0.tar.gz
sudo wget -O proj-datumgrid-1.8.tar.gz http://download.osgeo.org/proj/proj-datumgrid-1.8.tar.gz
sudo tar xvf proj-5.2.0.tar.gz
sudo tar xvf proj-datumgrid-1.8.tar.gz
cd proj-5.2.0
sudo ./configure
sudo make
sudo make install
sudo ldconfig
# GDAL
cd /
sudo mkdir -p /usr/local/gdal
cd usr/local/gdal
sudo wget -O gdal-2.4.4.tar.gz http://download.osgeo.org/gdal/2.4.4/gdal-2.4.4.tar.gz
sudo tar xvf gdal-2.4.4.tar.gz
cd gdal-2.4.4
sudo ./configure
sudo make
sudo make install
sudo ldconfig
As shown, the script checks whether gdal already exists using the test function. It then downloads the Geos, Proj, and GDAL libraries and installs them in the usr/local directory. At the time of writing this, geodjango (Django 3.0) supports up to Geos 3.7, Proj 5.2 (which also requires projdatum. Current releases do not require it), and GDAL 2.4 Warning: this installation process can take a long time. Also I am not a Linux professional so some of those commands may be redundant, but it works.
Lastly I add the following two environment variables to my Elastic Beanstalk configuration:
LD_LIBRARY_PATH: /usr/local/lib:$LD_LIBRARY_PATH
PROJ_LIB: usr/local/proj
If you still have troubles I recommend checking the logs and ssh-ing in the EC2 instance to check that installation took place. Original credit to this post
I have tried the following link to mount S3 bucket into EC2 :
https://forums.aws.amazon.com/message.jspa?messageID=313009
I started typing the following commands :
wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/s3fs/s3fs-1.74.tar.gz
tar zxf s3fs-1.74.tar.gz
apt-get install build-essential libxml2-dev libfuse-dev libcurl4-openssl-dev
sudo make install
The next command to type is this :
sudo touch /etc/passwd-s3fs-1.74 && sudo chmod 640 /etc/passwd-s3fs-1.74 && sudo echo 'Accesskey:SecretKey' > /etc/passwd-s3fs-1.74
But, when I type this, I get the following response :
-bash: /etc/passwd-s3fs-1.74: Permission denied
I am not root but used sudo.
May I know what's wrong with this??
Change directory to s3fs-1.74 and compile it as follows:
./configure --prefix=/usr
make
sudo make install
Verify it which s3fs
edit
To solve dependencies run: sudo apt-get install fuse libxml2-dev libssl-dev
To solve the permission issue run;
chown user:user /etc/passwd-s3fs-1.74
I have tried a lot of online posts to install opencv but they are not working for Ubuntu 16.04. May anyone please give me the steps to install openCV 2.4.13 on it?
There's a script I had made a while back, for installing the latest version of OpenCV (4.2 as of the last update to this answer)
Here's the link to it
https://github.com/rsnk96/Ubuntu-Setup-Scripts/blob/master/Build-OpenCV.sh
NOTE: For Ubuntu 16.10+, there are some minor dependency changes you will have to make. Have a look at the comments for the same.
Since you do not want to install opencv contrib, and you specifically want opencv 2.4.13, I have modified the script below. I would suggest you go through the script and understand what is happening before you execute it
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install build-essential -y
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev -y
sudo apt-get install python3-numpy python3-pip python3-scipy python3-matplotlib python-dev python-matplotlib python-numpy python-scipy -y
sudo apt-get install python-pip python-tk libqt4-dev libqt4-opengl-dev libeigen3-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev default-jdk ant -y
echo "GUI and openGL extensions"
sudo apt-get install qt4-default libqt4-opengl-dev libvtk5-qt4-dev libgtk2.0-dev libgtkglext1 libgtkglext1-dev -y
echo "image manipulation libraries"
sudo apt-get install libpng3 pngtools libpng12-dev libpng12-0 libpng++-dev -y
sudo apt-get install libjpeg-dev libjpeg9 libjpeg9-dbg libjpeg-progs libtiff5-dev libtiff5 libtiffxx5 libtiff-tools libjasper-dev libjasper1 libjasper-runtime zlib1g zlib1g-dbg zlib1g-dev -y
echo "video manipulation libraries"
sudo apt-get install libavformat-dev libavutil-ffmpeg54 libavutil-dev libxine2-dev libxine2 libswscale-dev libswscale-ffmpeg3 libdc1394-22 libdc1394-22-dev libdc1394-utils -y
echo "codecs"
sudo apt-get install libavcodec-dev -y
sudo apt-get install libfaac-dev libmp3lame-dev -y
sudo apt-get install libopencore-amrnb-dev libopencore-amrwb-dev -y
sudo apt-get install libtheora-dev libvorbis-dev libxvidcore-dev -y
sudo apt-get install ffmpeg x264 libx264-dev -y
sudo apt-get install libv4l-0 libv4l v4l-utils -y
echo "multiproccessing library"
sudo apt-get install libtbb-dev -y
echo "finally download and install opencv"
mkdir opencv
cd opencv
wget "https://github.com/opencv/opencv/archive/2.4.13.2.zip"
unzip opencv-2.4.13.2.zip
cd opencv-2.4.13.2
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DINSTALL_C_EXAMPLES=ON \
-DINSTALL_PYTHON_EXAMPLES=ON \
-DBUILD_EXAMPLES=ON \
-DBUILD_opencv_cvv=OFF \
-DBUILD_NEW_PYTHON_SUPPORT=ON \
-DWITH_TBB=ON \
-DWITH_V4L=ON \
-DWITH_QT=ON \
-DWITH_OPENGL=ON \
-DWITH_VTK=ON ..
echo "making and installing"
make -j8
sudo make install
echo "finishing off installation"
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
echo "Congratulations! You have just installed OpenCV. And that's all, folks! :P"
P.S. Create a script file out of this and then just execute the script file, rather than copy-pasting it line by line into the terminal. You can do that by copying all of it, placing it in a file with the extension .sh, and then simply running that .sh file from the terminal using $ ./filename.sh
According to this source, from Ubuntu 16.04, you can now just do this to install OpenCV for Python2.7:
pip install opencv-python
or for python3:
pip3 install opencv-python
For more information, see here.
I tested this on my machine and it works, great stuff this :).
This is much easier than all other methods I have come across thus far.
sudo apt-get install build-essential cmake git pkg-config
sudo apt-get install libjpeg8-dev libtiff4-dev libjasper-dev libpng12-dev
sudo apt-get install libgtk2.0-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libatlas-base-dev gfortran
sudo apt-get install python2.7-dev
sudo pip install numpy
sudo apt-get install python-opencv
Then you can have a try:
$ python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
>>> import cv2
If you have more than one opencv installation on your machine, now I tell you the most direct, effective and easy way to choose opencv version in python.
You can type the following command to check the current opencv version in python
import cv2
cv2.__version__
opencv path in python is set in system variable PYTHONPATH, you can echo this variable with echo $PYTHONPATH
If I want to use opencv3.x in python, then using vi or gedit open .bashrc in the home folder, add this content to the end
export PYTHONPATH=/home/ismart/ipa2/devel/lib/python2.7/dist-packages:/home/ismart/catkin_ws/install_isolated/lib/python2.7/dist-packages:/usr/local/opencv3.x/lib/python2.7/dist-packages
Replace the path with yours