Advanced Installation Guide =========================== The content in this document is a subsidiary to the :doc:`install` because it became disorganized and the number of possible Python installation combinations and snags intensified. However, that culminated in the collection of excellent information that is provided here. Please remember, the Splunk app install approach was introduced to alleviate several of these issues. A portion of this document is targeted at those who can't install packages as Admin or are forced to use Splunk's embedded Python. For everyone else, please start with the one-liner: .. code-block:: sh pip install -U ksconf This document includes some legacy information that may not longer be true. Generally speaking, installing Python packages has become much easier since Python 2 went away. However, there are still some weird corner cases out there so this document has be kept around for reference. .. tip:: **Do any of these words for phrases strike fear in your heart?** .. hlist:: :columns: 3 - ``pip`` - ``pipenv`` - ``virtualenv`` - ``wheel`` - ``pyenv`` (not the same as ``pyvenv``) - ``python3.7`` vs ``python37`` vs ``py -37`` - ``PYTHONPATH`` - ``LD_LIBARY`` - RedHat Software Collections If this list seems daunting, head over to :ref:`install_splunk_app`. There's no shame in it. .. contents:: Flowchart --------- (Unfinished; more of a brainstorm at this point…) - Is Python installed? (OS level) - Is the version greater than 3.7? - Do you have admin access? (root/Administrator; or can you get it? How hard? Will you need it each time you upgrade the ksconf?) - Do you already have a large Python deployment or dependency? (If so, you'll probably be fine. Use `venv`_) - Do you have any prior Python packaging or administration experience? - Are you dealing with some vendor-specific solution? - Example: RedHat Software Collections – where they realize their software is way too old, so they try to make it possible to install newer version of things like Python, but since they aren't native or the default, you still end up jumping through a bunch of wonky hoops) - Do you have Internet connectivity? (air gap or blocked outbound traffic, or proxy) - Do you want to build/deploy your own ksconf extensions? If so, the Python package is a better option. (But at that point, you can probably already handle any packaging issues yourself.) Installation ------------ There are several ways to install ksconf. Technically, all standard Python packaging approaches should work just fine. However, for non-Python developers, there are some snags. Installation options are listed from the most easy and recommended, to more obscure and difficult: Install from PyPI with PIP ~~~~~~~~~~~~~~~~~~~~~~~~~~ The preferred installation method is to install via the standard Python package tool :command:`pip`. Ksconf can be installed via the registered `ksconf`_ package using the standard Python process. There are 2 popular variations, depending on whether or not you would like to install for all users or test it locally. Install ksconf into a virtual environment ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ **Use this option if you don't have admin access** Installing ``ksconf`` with venv is a great way to test the tool without requiring admin privileges and has many advantages for a production install. Here are the basic steps to get started. .. note:: Virtualenv vs venv We used to recommend using virtualenv_, which worked with Python 2 and 3. But since Python now ships with venv_, there's no functional differences between the two approaches, we now suggest using 'venv'. That being said, virtualenv still works fine and will continue to be supported. Please change ``venv`` to a suitable path for your environment. .. code-block:: sh # Create and activte new 'venv' virtual environment python3 -m venv venv source venv/bin/activate pip install ksconf .. note:: Windows users The above virtual environment activation should be run as :file:`venv\\Scripts\\activate.bat`. Install ksconf system-wide ^^^^^^^^^^^^^^^^^^^^^^^^^^ .. important:: This requires admin access. This is the absolute easiest install method where 'ksconf' is available to all users on the system but it requires root access and ``pip`` must be installed and up-to-date. On Mac or Linux, run: .. code-block:: sh sudo pip install ksconf On Windows, run this command from an Administrator console. .. code-block:: sh pip install ksconf CentOS (RedHat derived) distros ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: sh # Enable the EPEL repo so that `pip` can be installed. sudo yum install -y epel-release # Install pip sudo yum install -y python-pip # Install ksconf (globally, for all users) sudo pip install ksconf RedHat Software Collections ^^^^^^^^^^^^^^^^^^^^^^^^^^^ The following assumes the ``python38`` software collection, but other version of Python are supported too. The initial setup and deployment of Software Collections is beyond the scope of this doc. .. code-block:: sh sudo scl enable python38 python -m pip install ksconf .. hint:: Missing pip? If pip is missing from a RHSC, then install the following rpm. .. code-block:: sh yum install python38-python-pip Unfortunately, the ``ksconf`` entrypoint script (in the ``bin`` folder) will not work correctly on it's own because it doesn't know about the scl environment, nor is it in the default PATH. To solve this, run the following: .. code-block:: sh sudo cat > /usr/local/bin/ksconf < $SPLUNK_HOME/bin/ksconf <`__ - `'pip install' fails for every package ("Could not find a version that satisfies the requirement") `__ No module named 'command.install' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If, while trying to install ``pip`` or run a ``pip`` command you see the following error: :: ImportError: No module named command.install Likely this is because you are using a crippled version of Python; like the one that ships with Splunk. This won't work. Either install the Splunk app package from Splunkbase or install using the OS-level Python. .. _python_troubleshooting: Troubleshooting --------------- Here are a few fact gathering type commands that may help you begin to track down problems. Check Python version ~~~~~~~~~~~~~~~~~~~~ Check your installed Python version by running: .. code-block:: sh python --version Note that Linux distributions and Mac OS X that ship with multiple versions of Python may have renamed this to ``python3``, ``python3.8`` or similar. Check PIP Version ~~~~~~~~~~~~~~~~~ .. code-block:: sh pip --version If you are running a different Python interpreter version, you can instead run this as: .. code-block:: sh python3 -m pip --version .. _adv_validate_install: Validate the install ~~~~~~~~~~~~~~~~~~~~ Confirm installation with the following command: .. code-block:: sh ksconf --version If this works, it means that ``ksconf`` installed and is part of your ``PATH`` and should be useable everywhere in your system. Go forth and conquer! If this doesn't work, here are a few things to try: 1. Check that your ``PATH`` is set correctly. 2. Try running ksconf as a "module" (sometimes works around a PATH issue). Run ``python -m ksconf`` 3. If you're running the Splunk app, try running the following: .. code-block:: sh cd $SPLUNK_HOME/etc/apps/ksconf/bin/lib python -m ksconf --version If this works, then the issue is with PATH. It may be helpful to uninstall (remove) the Splunk app and reinstall from scratch. Resources --------- - `Python packaging `__ docs provide a general overview on installing Python packages, how to install per-user vs install system-wide. - `Install PIP `__ docs explain how to bootstrap or upgrade ``pip`` the Python packaging tool. Python 3 comes with this by default, but some Linux distros break this into a separate package. .. include:: common