====== Python ====== ===== Installation and Requirements ===== Mystic BBS has an embedded Python scripting engine called Mystic Python. This engine is based off of Python v2.7 and Python 3.x and is compatible with all code and modules for each of them. In order for this to function properly, Mystic requires that Python 2.7 or 3.x is installed on the operating system. Python is not a a dependency for Mystic to function, so if you do not plan to execute Python scripts then you do not need to have Python installed. **NOTE: The "bit level" of Python must match the "bit level" of Mystic and the operating system. If you are using a 32-bit version of Mystic you should install the 32-bit version of Python. If you are using the 64-bit version of Mystic you should install the 64-bit version of Python. Be particularly careful when selecting your installation download in Windows as the website is not very clear on which version you are getting.** In Windows, Python needs to be installed by downloading it from the Website:[[http://www.python.org|www.python.org]] In Linux, most come with either Python 2.7 or 3.x pre-installed. **NOTE: With Linux, it may not be possible to mix and match versions of Python with Mystic. In other words, if you want to use 3rd party modules then you're going to have to choose between Python 2.7 and 3.x. If you attempt to mix and match scripts you may experience script execution exceptions. Windows does not have this limitation.** ==== Library Validation / Installation ==== When initializing Python, Mystic will be attempting to locate the following libraries depending on operating system: Python 2.x: Windows: python27.dll Linux: libpython2.7.so.1.0 MacOS: libpython2.7.dylib Python 3.x Windows: python3xx.dll (Where xx is the minor version. Ex: python39.dll, python310.dll) Linux: libpython3.xx.so.1.0 (Where XX is the minor version. Ex: libpython3.9.so.1.0) MacOS: libpython3.xx.dylib (Where XX is the minor version) Mystic will search in known locations for Python libraries as listed below in order of search: Windows: 32-bit: C:\Windows\System32, Current directory, C:\Windows\SysWOW64 64-bit: C:\Windows\SysWOW64, Current directory Linux: Intel 32-bit: /lib/i386-linux-gnu, /lib, /usr/lib, /usr/local/lib, Current directory Intel 64-bit: /lib/x86_64-linux-gnu, /lib, /usr/lib, /usr/local/lib, Current directory ARM: /lib, /usr/lib, /usr/local/lib, Current directory In the event that Mystic cannot find the Python libraries, it may be required to override Mystic's internal search and supply the actual path and filename of the Python library. This can be done in Mystic's System Configuration in the General Settings category. You will find Python2 and Python3 library fields which you can specify the full path and filename of the Python 2 and libraries. In Linux you can check to see where you may have Python installed using ldconfig: ldconfig -p | grep libpython ==== Missing Python ==== For Windows, simply go to the Python website and download, install Python. For Linux you can try to install by package manager, although it is VERY unlikely you have a Linux OS without a Python version installed. Newer operating systems may be missing Python 2.7 and may have packages that are not compiled properly. The following steps can be used to reinstall Python 2.7 by compiling it, if the package is not available or if the package installed does not work. This was tested on a fresh Ubuntu 18.04 LTS: **INSTALL PREREQUISITES:** * sudo apt-get update * sudo apt-get install build-essential checkinstall * sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev **COMPILE PYTHON:** * cd /usr/src * sudo wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tgz * sudo tar xzf Python-2.7.15.tgz * cd /usr/src/Python-2.7.15 * sudo ./configure -enable-optimizations -enable-unicode=ucs4 -enable-shared * sudo make install