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
python_install [2019/02/02 16:58] – [Troubleshooting] g00r00python_install [2023/01/08 12:24] (current) 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 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 dependency for Mystic to function, so if you do not plan to execute Python scripts then you do not need to have Python installed
-   + 
-Most Linux desktop distributions and Apple's macOS will come with Python 2.7 installed by default, and in many cases no installation will be required in order to use Python.  If not, it can typically be installed by 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 Mystic and the operating system.  If you are using 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:** If you are using the 32-bit version of Mystic (even if it is in a 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.+**NOTEWith Linuxit 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 ==== ==== Library Validation / Installation ====
  
-When initializing Python, Mystic will be attempting to locate the following library depending on operating system:+When initializing Python, Mystic will be attempting to locate the following libraries depending on operating system
 + 
 +Python 2.x:
  
   Windows: python27.dll   Windows: python27.dll
Line 17: Line 23:
   MacOS: libpython2.7.dylib   MacOS: libpython2.7.dylib
  
-In Windows, you should probably know if Python is installed already since it has to be manually installed.+Python 3.x
  
-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.  +  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:
  
-You can check to see if you have the proper library installed by searching the results of ldconfig+Windows
- +  32-bit: C:\Windows\System32, Current directory, C:\Windows\SysWOW64 
-  ldconfig -p | grep libpython2.7.so.1.0+  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
      
-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. +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 and libraries. 
- +  
-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:+In Linux you can check to see where you may have Python installed using ldconfig:
  
   ldconfig -p | grep libpython   ldconfig -p | grep libpython
  
-The result will tell you where Python 2.7 is installed.  If Python 2.7 is installed under a different library name, then you will need to create a symbolic link to that filename using "libpython2.7.so.1.0" so Mystic can find it. 
  
-If you cannot locate libpython2 then it may be that you do not have Python 2 installed or that you have a partial installation of Python 2.  You will likely need to install Python 2.7 and then possibly create a symbolic link as described above.  This can typically be installed by a package manager, as shown below on a Raspbian installation:+==== Missing Python ====
  
-  sudo apt-get update +For Windows, simply go to the Python website and download, install Python.
-  sudo apt-get install libpython2.7+
  
-==== Environment Variables ====+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.
  
-In addition to the basic Python installation, some environment variables may need to be set so that Mystic can find and import 3rd party modules used within your Python programs.  In many cases the default installation will work just fine and no modifications will be needed.  However, if an error occurs when executing modules, then the environment variables may need to be set or adjusted. +The following steps can be used to reinstall Python 2.by compiling it, if the package is not available or if the package installed does not work.  This was tested on fresh Ubuntu 18.04 LTS:
- +
-One common error reported when the environment variables need adjusted or set is the message "**Importerror: No module named site**" printed to STDOUT. +
- +
-**PYTHONHOME** and **PYTHONPATH** are two environment variables which need to be set.  Depending on your operating system, Python may already be installed and working without making any changes As an example, if you have Python installed to C:\PYTHON27 in Windows, you'd want to set environment variables as such: +
- +
-   SET PYTHONHOME=C:\PYTHON27 +
-   SET PYTHONPATH=C:\PYTHON27\LIB +
-   SET PATH=%PYTHONHOME%;%PATH% +
- +
-For more information on how to set environment variables, you'll need to research the specific operating system that you are using and the Python documentation.  For reference: Here is what the Python documentation says about these environment variables: +
- +
-     PYTHONHOME +
-     +
-     Change the location of the standard Python libraries. By default, the +
-     libraries are searched in prefix/lib/pythonversion and +
-     exec_prefix/lib/pythonversion, where prefix and exec_prefix are +
-     installation-dependent directories, both defaulting to /usr/local. +
-     +
-     When PYTHONHOME is set to a single directory, its value replaces both +
-     prefix and exec_prefix. To specify different values for these, set +
-     PYTHONHOME to prefix:exec_prefix. +
-     +
-     PYTHONPATH +
-     +
-     Augment the default search path for module files. The format is the same +
-     as the shell’s PATH: one or more directory pathnames separated by +
-     os.pathsep (e.g. colons on Unix or semicolons on Windows). Non-existent +
-     directories are silently ignored. +
-     +
-     In addition to normal directoriesindividual PYTHONPATH entries may +
-     refer to zipfiles containing pure Python modules (in either source or +
-     compiled form). Extension modules cannot be imported from zipfiles. +
-     +
-     The default search path is installation dependent, but generally begins +
-     with prefix/lib/pythonversion (see PYTHONHOME above). It is always +
-     appended to PYTHONPATH. +
-     +
-     An additional directory will be inserted in the search path in front of +
-     PYTHONPATH as described above under Interface options. The search path +
-     can be manipulated from within a Python program as the variable sys.path +
- +
-==== Troubleshooting ==== +
- +
-For more information, read the documentation above. +
- +
-=== Windows === +
- +
-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. +
- +
-=== Unix === +
- +
-The most common issue in Unix based platforms is that a link is not created to the Python library.  Mystic expects to find "libpython2.7.so.1.0" on Linux and "libpython2.7.dylib" in macOS, so if your Python library is stored under a different name then you need to make a symbolic link. +
- +
-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 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:** **INSTALL PREREQUISITES:**
Line 113: Line 65:
   * sudo tar xzf Python-2.7.15.tgz   * sudo tar xzf Python-2.7.15.tgz
   * cd /usr/src/Python-2.7.15   * cd /usr/src/Python-2.7.15
-  * sudo ./configure --enable-optimizations --enable-unicode=ucs4 --enable-shared+  * sudo ./configure -enable-optimizations -enable-unicode=ucs4 -enable-shared
   * sudo make install   * sudo make install
- 
-**CREATE LINK TO PYTHON:** 
-  * sudo ln -s /usr/local/bin/python2.7 /usr/bin/python 
  
python_install.1549148302.txt.gz · Last modified: 2019/02/02 16:58 by g00r00

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki