This is a simple guide on how to install python on a Solaris 9 system. There are a few gotcha's which I am sharing and writing for future use.
1.
Download Python. I took the compressed source tarball (.tgz). You are essentially compiling the source on your system.
2.
Optional: Transferring it to the server. I had to transfer it to the server to install, so if you need to do that, see my
previous post
3. Unzip the package using the following command. It will unzip, then untar.
Code Snippet
gunzip -c PYTHONFILENAME.tgz |tar xvf -
4. You now need to configure the source. This will produce a Makefile based on your system. Navigate to the Python source directory, and execute the following command...
Code Snippet
./configure --prefix=/usr/local
5. Now we need to compile our Makefile that has been created.
6. Ensure you are a root user before this step ("su root" - to change). Execute the following command to install Python.
Code Snippet
make -i install
7. If everything went well (it probably didn't - see below!). Add Python to your system PATH variable. This way, you don't need to refer to /usr/local everytime you execute a script. See my
previous blog post on how to do this.
8. Simply execute the following command to check Python has set itself up correctly... Do this outside of the source directory, so you can test the PATH variable aswell.
Code Snippet
python --version
9. Get an ice cold beerski in!
Troubleshooting
During the
make procedure, you receive the following...
./Parser/asdl_c.py -c ./Python ./Parser/Python.asdl
/usr/bin/env: No such file or directory
make: *** [Python/Python-ast.c] Error 127
Simply touch the libraries it requires (see below), and re-try... (Run
make clean before re-try)
Code Snippet
touch Include/Python-ast.h Python/Python-ast.c
During the install procedure, you receive the following...
make: ar: Command not found
You need to add
ar to your PATH variable. This is located in /usr/ccs/bin. See my
previous blog post on how to do this.
Note: If you are receiving an error while re-trying or you wish to remove temporary install files, simply execute the following command... "
make clean"
Optional: Adding SSL Support to Python
Python needs to be compiled with SSL support... You can enable this by firstly installing the OpenSSL development libraries (
libssl-dev download here) before the initial Python installation. Ensure you can open the OpenSSL console by typing openssl... If not, add it to your PATH. You then uncomment a few lines from the Modules/Setup.dist file.
Open the 'Modules/Setup.dist' file for editing, and uncomment the following lines (Assuming you installed OpenSSL to the default location)...
Code Snippet
204: # Socket module helper for SSL support; you must comment out the other
205: # socket line above, and possibly edit the SSL variable:
206: SSL=/usr/local/ssl
207: _ssl _ssl.c \
208: -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
209: -L$(SSL)/lib -lssl -lcrypto</pre>
Save and close the file... then copy the file to /Setup. Otherwise Python will warn you this this file is newer than the Setup copy. You can now proceed to install Python with the instructions as above.
You can verify the installation by running the following test script...
Code Snippet
python /usr/local/lib/python2.5/test/test_socket_ssl.py
Module Errors
If you experience any errors with modules... then execute python's setup.py file. This will install all of the modules by default.
Code Snippet
python setup.py install