Search code examples
ubuntuinstallationckan

Failing to install CKAN 2.8.3 from source when following documentation


I am trying to get CKAN 2.8.3 installed on a freshly provisioned Ubuntu 18.4 VM. Before starting I have updated all apt packages.

I follow the instruction on https://docs.ckan.org/en/latest/maintaining/installing/install-from-source.html

I am able to follow the guide until the step "For Python 2 adjust the filename to: requirements-py2.txt" which I assume means that I should run the command "pip install -r /usr/lib/ckan/default/src/ckan/requirements-py2.txt". This file doesn't exist, but the /usr/lib/ckan/default/src/ckan/requirements.txt does. What can I be doing wrong, or is the documentation out of date?

Clarification of which commands was executed on a plain Ubuntu 18.4 Azure VM:

#Added by me
sudo apt update
sudo apt upgrade
#From the guide
mkdir -p ~/ckan/lib
sudo ln -s ~/ckan/lib /usr/lib/ckan
mkdir -p ~/ckan/etc
sudo ln -s ~/ckan/etc /etc/ckan
sudo mkdir -p /usr/lib/ckan/default
sudo chown `whoami` /usr/lib/ckan/default
virtualenv --python=/usr/bin/python2.7 --no-site-packages /usr/lib/ckan/default
. /usr/lib/ckan/default/bin/activate
pip install setuptools==36.1
pip install --upgrade pip
pip install -e 'git+https://github.com/ckan/[email protected]#egg=ckan'
pip install -r /usr/lib/ckan/default/src/ckan/requirements-py2.txt

At this point I get the error that there is no requirements-py2.txt file:

(default) myusername@myhostname:~$ pip install -r /usr/lib/ckan/default/src/ckan/requirements-py2.txt
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
ERROR: Could not open requirements file: [Errno 2] No such file or directory: '/usr/lib/ckan/default/src/ckan/requirements-py2.txt'
(default) myusername@myhostname:~$

Edit: Correction - I accidentally wrote 1.8.3, not 2.8.3

Addition: I have also tried at this point to run

pip install -r /usr/lib/ckan/default/src/ckan/requirements.txt

This works fine, however, if I continue with:

sudo -u postgres createuser -S -D -R -P ckan_default
sudo -u postgres createdb -O ckan_default ckan_default -E utf-8
sudo mkdir -p /etc/ckan/default
sudo chown -R `whoami` /etc/ckan/
ckan generate config /etc/ckan/default/ckan.ini

It fails by not being able to find the command ckan:

(default) myusername@myhostname:~$ ckan generate config /etc/ckan/default/ckan.ini

Command 'ckan' not found, did you mean:

  command 'cpan' from deb perl
  command 'ckon' from deb ckon

Try: sudo apt install <deb name>

(default) myusername@myhostname:~$

Solution

  • In regards to your problems executing the pip requirements command on the requirements-py2.txt file. This file only exists on the latest version of ckan as they are migrating form python 2.7 to python 3. On older versions of ckan such as the one you are running, the requirements file is already tailored for python 2.7

    You may wish to reference the documentation for ckan 2.8 specifically rather than the latest version https://docs.ckan.org/en/2.8/maintaining/installing/install-from-source.html

    For your second issue. In order to run the ckan generate config command you need to first activate the python virtual environment. This is done as following:

    . /usr/lib/ckan/venv/bin/activate
    

    Then followed by:

    paster make-config ckan /etc/ckan/default/development.ini