User Tools

Site Tools


python_install

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
python_install [2018/01/01 14:50] – [Troubleshooting] g00r00python_install [2019/03/10 09:18] – [Troubleshooting] g00r00
Line 3: Line 3:
 ===== Installation and Requirements ===== ===== Installation and Requirements =====
  
-Mystic requires that Python 2.7 is installed on your system if you wish to execute Python scripts.  The presence of Python is detected automatically by Mystic, and is initialized as needed.  It is not in any way a dependency and Mystic will continue to operate normally without it should you decide you do not wish to use it. +Mystic BBS has an embedded Python scripting engine called Mystic Python.  This engine is based on Python 2.7 and is compatible with all Python 2.7 code and modules.  In order for this to function properly, Mystic requires that Python 2.7 is installed on the operating system.  Python is not 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 if you do not wish to use it. 
-   + 
-Most Linux desktop distributions and Apple's macOS will come with Python 2.7 installed by defaultand in many cases no installation will be required in order to use Python.  If not, it can typically be installed by a package manager in Unix (explained below).  In Windows, Python needs to be installed by downloading it from the Website: [[http://www.python.org|www.python.org]]+**Note:** The "bit level" of Python must match the "bit level" of Mysticso 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! 
 + 
 +In Windows, Python needs to be installed by downloading it from the Website:[[http://www.python.org|www.python.org]] 
 + 
 +Most Linux desktop distributions and MacOS will come with Python 2.7 installed by default, and in some cases full Mystic Python functionality will work out of the box without additional steps.  However some of the more popular installations such as Ubuntu and Mint Linux do not come with Python installed with shared libraries enabled, which means it will not work with embedded Python applications like Mystic.
  
-**Note:** If you are using the 32-bit version of Mystic (even if it is in 64-bit operating system), then you need the 32-bit version of Python installed.  If you are using the 64-bit version of Mystic then you need to have the 64-bit version of Python installed.  This is a very common mistake, particularly on the Windows platform where SysOps will download the wrong bit-version of Python.+If you are using a Linux operating system with this issue then modules such as "sqlite3" will fail when they are included in a script with an error mentioning Py_ZeroStruct.  In order to fix this issue, a new Python will have to be compiled in a way that is compatible with Mystic.  See the Troubleshooting section below for steps to compile and install Python properly.
  
 ==== Library Validation / Installation ==== ==== Library Validation / Installation ====
Line 19: Line 23:
 In Windows, you should probably know if Python is installed already since it has to be manually installed. In Windows, you should probably know if Python is installed already since it has to be manually installed.
  
-In Linux environments, you can usually determine if Python is installed by executing "python --version" in a terminal window.  The version should be 2.7.  You can also check to see if you have the proper library installed by searching the results of ldconfig:+In Linux environments, you can usually determine if Python is installed by executing "python --version" in a terminal window.  The version should be 2.7.   
 + 
 +You can check to see if you have the proper library installed by searching the results of ldconfig:
  
   ldconfig -p | grep libpython2.7.so.1.0   ldconfig -p | grep libpython2.7.so.1.0
      
 +Note that some Linux distributions come with a Python 2.7 package or installation that is compiled in a way that does not work well with embedded Python applications.  For more information regarding this and how to fix it, see the Troubleshooting section below.
 +
 If the above command does not find anything but "python --version" prints 2.7, then you may have Python installed under a different library name.  Execute the same command with just the base library name to locate where Python is installed: If the above command does not find anything but "python --version" prints 2.7, then you may have Python installed under a different library name.  Execute the same command with just the base library name to locate where Python is installed:
  
Line 85: Line 93:
  
 The most common Windows issue is that the wrong version of Python is installed.  It is absolutely a requirement that you download the 32-bit version of Python if using 32-bit version of Mystic, and the 64-bit version of Python if using the 64-bit version of Mystic. The most common Windows issue is that the wrong version of Python is installed.  It is absolutely a requirement that you download the 32-bit version of Python if using 32-bit version of Mystic, and the 64-bit version of Python if using the 64-bit version of Mystic.
 +
 +If you get an error similar to "“Importerror: No module named site" when your script tries to import a module, this
 +means you need to set your Python environment variables.  See the section above for information and an example of
 +how to do this in Windows.
  
 === Unix === === Unix ===
Line 91: Line 103:
  
 Like the Windows version, another issue some people have ran into is that their bit level of Python does not match that of Mystic which can cause crashes when a script is attempting to execute.  The issue seems more prominent in macOS where the owner may not be aware of their OS bit-level, or their OS has a mix and match of 32-bit and 64-bit software and it is not clear what version they should be using. Like the Windows version, another issue some people have ran into is that their bit level of Python does not match that of Mystic which can cause crashes when a script is attempting to execute.  The issue seems more prominent in macOS where the owner may not be aware of their OS bit-level, or their OS has a mix and match of 32-bit and 64-bit software and it is not clear what version they should be using.
 +
 +**NOTE: Some Linux distributions come with a pre-installed Python 2.7 or a package-based install of Python 2.7 that is not compiled in a way that works properly with embedded Python applications.**
 +
 +When Python is compiled wrong, it will have issues loading some modules resulting in an error when you execute the Mystic Python script.  One of the most popular operating systems (Ubuntu) unfortunately seems to suffer from this problem, and the only way to solve it is to recompile Python 2.7 properly.  The enable-shared option is required
 +for embedded applications, and also the unicode size may need to be either ucs2 or ucs4.
 +
 +The following steps can be used to reinstall Python 2.7 on 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
 +
python_install.txt · Last modified: 2023/01/08 12:24 by g00r00

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki