Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Monday, September 26, 2016

Python-yaml Libraries for Python 3

If you are searching for Python-yaml and not able to locate the libraries, you might want to try

# ./pip search yaml

You should see something like pyyaml
# ./pip install -upgrade  pyyaml

Wednesday, April 22, 2015

Installing scipy and other scientific packages using pip3 for Python 3.4.1

I wanted to install the packages using pip3. Before you can successfully install the python packages, do note that you have to make sure the following packages are found in your CentOS 6.


# yum install blas blas-devel lapack lapack-devel numpy

After you install according to Compiling and Configuring Python 3.4.1 on CentOS The packages that I want to install are numpy scipy matplotlib ipython ipython[notebook] pandas sympy nose


# /usr/local/python-3.4.1/bin/pip install numpy
# /usr/local/python-3.4.1/bin/pip install scipy
# /usr/local/python-3.4.1/bin/pip install matplotlib
# /usr/local/python-3.4.1/bin/pip install ipython[notebook]
# /usr/local/python-3.4.1/bin/pip install pandas
# /usr/local/python-3.4.1/bin/pip install sympy
# /usr/local/python-3.4.1/bin/pip install nose

Wednesday, January 14, 2015

Compiling and Configuring Python 3.4.1 on CentOS

Step 1: Remember to turn on RPMForge and EPEL Repository. For more information on repository, see Repository of CentOS 6 and Scientific Linux 6 

Step 2: Download Python-3.4.1 from the Python Download Page

Step 3: Install Prerequisite Software
# yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel

Step 4: Configure and Build
# cd /installation_home/Python-3.4.1
# ./configure --prefix=/usr/local/python-3.4.1
# make
# make install

Step 5: Check that scripts query the correct interpreter:
#/usr/local/python3/bin/python3

Step 6: Install Scientific Components (Optional: If you requires it) Scipy Stack (for scientific packages in python)
# yum install numpy scipy python-matplotlib ipython python-pandas sympy python-nose

Step 7: Install Python Modules (whatever you need. Here is an example)
# /usr/local/python-3.4.1/bin/pip3 install networkx

Thursday, July 24, 2014

Using pip to install python packages

Pointer 1: To install specific version of packages do
# pip install 'numpy==1.5.1'
Pointer 2: To show what files was installed
# pip show --files numpy
---
Name: numpy
Version: 1.8.1
Location: /usr/local/python-2.7.8/lib/python2.7/site-packages
Requires:
Files:
../numpy/__init__.py
.....
.....
Pointer 3: Uninstall a package
# pip uninstall num
Uninstalling SomePackage:
Pointer 4: Upgrade a package:
# pip install --upgrade SomePackage
[...]
Found existing installation: SomePackage 1.0
Uninstalling SomePackage:
Successfully uninstalled SomePackage
Running setup.py install for SomePackage
Successfully installed SomePackage
Pointer 5: List what packages are outdated:
# pip list --outdated
SomePackage (Current: 1.0 Latest: 2.0)
References:
  1. pip 1.5.6 - A tool for installing and managing Python packages
  2. pip - installation

Wednesday, July 23, 2014

Installing and Compiling Python 2.7.8 on CentOS 5

Step 1: Download the Python 2.7.8 from Python Site Step 2: Use GCC44 to compile. If you have not done it, do
# yum install gcc44 gcc44-c++ gcc44-gfortran
Step 3: Update your alias in your .bashrc
alias gcc='gcc44'
Step 4: Configure python 2.7.8
# cd python-2.7.8
# ./configure --prefix=/usr/local/python-2.7.8
# make -j 8
# make install
Step 5: Update the PATH and LD_LIBRARY_PATH in your .bashrc
export PATH=$PATH:/usr/local/python-2.7.8/bin.........
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/python-2.7.8/lib
Step 6: Download get-pip.py For more information see pip installation site Create a directory inside python2.7 directory and put pip in that directory
# mkdir /usr/local/python-2.7.8/pip
# wget https://bootstrap.pypa.io/get-pip.py .
Step 7: Install pip with Administrator rights
# python2.7 get-pip.py
If setuptools (or distribute) is not already installed, get-pip.py will install setuptools for you. To upgrade an existing setuptools (or distribute), run
# pip install -U setuptools
# pip install numpy

Thursday, July 17, 2014

/usr/lib64/libxml2.a: could not read symbols: Bad value

For more information on how to install python 2.7 and python-igraph, do look at the blog entry


When I was install python-igraph, I encountered the error
# python2.7 setup.py install

/usr/bin/ld: /usr/lib64/libxml2.a(entities.o): 
relocation R_X86_64_32 against `a local symbol' 
can not be used when making a shared object; recompile with -fPIC 

/usr/lib64/libxml2.a: could not read symbols: Bad value

The solution for this can be found igraph-help http://lists.gnu.org/archive/html/igraph-help/2014-05/msg00045.html

If summary, rename the libxml2.a to libxml2.a.org to ensure that the setup script of the Python interface does not find it when needed -- the installer will then fall back to /usr/lib64/libxml2.so (i.e. the dynamic version of the libxml2 library)
# mv /usr/lib64/libxml2.a /usr/lib64/libxml2.a.org

When I was install python-igraph, I encountered the error

# python2.7 setup.py install

/usr/bin/ld: /usr/lib64/libm.a(entities.o): 
relocation R_X86_64_32 against `a local symbol' 
can not be used when making a shared object; recompile with -fPIC 

# mv /usr/lib64/libm.a /usr/lib64/libm.a.org

Tuesday, November 26, 2013

Installing HTseq for python 26 for CentOS 6

Installing HTseq is very straightforward for CentOS 6. You will need to do just follow the installation manual

# yum install python-devel numpy python-matplotlib

Download and untar the HTSeq source files.
# tar -zxvf HTSeq-0.5.4p5.tar.gz
# cd HTSeq-0.5.4p5

Inside the expanded HTSeq home directories, to make HTSeq available for all users
# python setup.py build
# python setup.py install

For more information, do look at
  1. HTSeq Prerequisites and Installation

Monday, March 19, 2012

No module named numpy when executing alpspython on CentOS 5

I was using testing out alps-2.0.2 on CentOS 5.4 .When I typed the following:

$ /usr/local/alps2.0.2/bin/alpspython

$ import pyalps

I got this error instead

Traceback (most recent call last):

  File "", line 1, in ?
  File "/usr/local/alps-2.0.2/lib/pyalps/__init__.py", line 37, in ?
    from dataset import *
  File "/usr/local/alps-2.0.2/lib/pyalps/dataset.py", line 29, in ?
    import numpy as np
ImportError: No module named numpy

The resolution was easier than I thought, just do a
# yum install python-numpy
The respective libraries will be installed

Friday, February 11, 2011

Python Error "Could not find platform independent libraries"

I encountered this error after I configure Python.

Could not find platform independent libraries 
Could not find platform dependent libraries 
Consider setting $PYTHONHOME to [:]
ImportError: No module named site

Actually, this error can be eliminated once I did a make install. Sometimes, even we system admin forget the simplest thing to do. Sigh

After you untar the python package, do a
# ./configure
# make 
# make install

Wednesday, October 20, 2010

CPLEX Installation with Python on CentOS

Following up on this blog entry Free Full version of ILOG Optimization products via IBM's Academic Initiative Program

1. After getting the necessary software and license from IBM Academic Initiative, you should install the CPLEX binary

# ./cplex_studio122.acad.linux-x86.bin

2. For the license file, make use your license file name is "access.ilm" (without the quotation)

3. Create a folder to house the license. CPLEX needs this folder to be present
# mkdir -p /usr/ilog/ilm
# mv access.ilm /usr/ilog/ilm

4. You should be able to run your CPLEX now. To verify, go to the CPLEX binary folder and run it. In my case
# /usr/local/cplex_studio_122/cplex/bin/x86-64_sles10.4.1/cplex

5. To install the Python API of CPLEX, do read up on IBM iLOG Optimization Studio Documentation
# cd /usr/local/cplex_studio_122/cplex/python/x86-64_sles10_4.1/
# python setup.py install --home ./cplex/

You will need to add the path to your PYTHONPATH by running
export PYTHONPATH=$PYTHONPATH:/usr/local/cplex_studio_v12/cplex/python/x86-64_sles10_4.1

Tuesday, October 5, 2010

Loading Mod_Python on Apache 2.x on CentOS 4.x and CentOS 5.x

Loading Python on Apache is easy. The material is taken from Mod Python ArchLinux Wiki

Configure Apache
# vim /etc/httpd/conf/httpd.conf

LoadModule python_module modules/mod_python.so

Restart Apache
# service restart httpd

Test Mod_Python
1. Add this block to /etc/httpd/conf/httpd.conf
<Directory /home/www/html> 
   AddHandler mod_python .py
   PythonHandler mod_python.publisher 
   PythonDebug On 
</Directory>

2. Create a file in /home/www/html/ called mptest.py and add this as contents

from mod_python import apache
def handler(req):
req.content_type = 'text/plain'
req.send_http_header()
req.write("Hello World!")
return apache.OK

Restart Apache again
# service restart httpd

Navigate to http://www.yoursite.com/mphandler.py/handler and you should see a site that says
Hello World!