MacLochlainns Weblog

Michael McLaughlin's Technical Blog

Site Admin

Archive for the ‘Linux’ Category

Fedora User Manager

without comments

As one of my students pointed out, Fedora doesn’t install a GUI user management tool installed by default. That’s true. It’s easy to install. You can install it as the root user, like:

yum install -y system-config-users

It should generate a screen console output like this when successfully installed:

Loaded plugins: langpacks, refresh-packagekit
http://yum.postgresql.org/9.3/fedora/fedora-20-x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
Resolving Dependencies
--> Running transaction check
---> Package system-config-users.noarch 0:1.3.6-1.fc20 will be installed
--> Processing Dependency: libuser-python >= 0.56 for package: system-config-users-1.3.6-1.fc20.noarch
--> Processing Dependency: python-pwquality for package: system-config-users-1.3.6-1.fc20.noarch
--> Running transaction check
---> Package libuser-python.x86_64 0:0.60-3.fc20 will be installed
---> Package python-pwquality.x86_64 0:1.2.3-1.fc20 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package                   Arch         Version             Repository     Size
================================================================================
Installing:
 system-config-users       noarch       1.3.6-1.fc20        updates       332 k
Installing for dependencies:
 libuser-python            x86_64       0.60-3.fc20         fedora         51 k
 python-pwquality          x86_64       1.2.3-1.fc20        fedora         11 k
 
Transaction Summary
================================================================================
Install  1 Package (+2 Dependent packages)
 
Total download size: 395 k
Installed size: 1.9 M
Downloading packages:
(1/3): libuser-python-0.60-3.fc20.x86_64.rpm                |  51 kB  00:00     
(2/3): python-pwquality-1.2.3-1.fc20.x86_64.rpm             |  11 kB  00:00     
(3/3): system-config-users-1.3.6-1.fc20.noarch.rpm          | 332 kB  00:00     
--------------------------------------------------------------------------------
Total                                              212 kB/s | 395 kB  00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : python-pwquality-1.2.3-1.fc20.x86_64                         1/3 
  Installing : libuser-python-0.60-3.fc20.x86_64                            2/3 
  Installing : system-config-users-1.3.6-1.fc20.noarch                      3/3 
  Verifying  : system-config-users-1.3.6-1.fc20.noarch                      1/3 
  Verifying  : libuser-python-0.60-3.fc20.x86_64                            2/3 
  Verifying  : python-pwquality-1.2.3-1.fc20.x86_64                         3/3 
 
Installed:
  system-config-users.noarch 0:1.3.6-1.fc20                                     
 
Dependency Installed:
  libuser-python.x86_64 0:0.60-3.fc20   python-pwquality.x86_64 0:1.2.3-1.fc20  
 
Complete!

You can verify the GUI user management tool is present with the following command:

which system-config-users

It should return this:

/bin/system-config-users

You can run the GUI user management tool from the root user account or any sudoer account. The following shows how to launch the GUI User Manager from a sudoer account:

sudo system-config-users

It will generate the following GUI User Manager screen:

As always, I hope this helps those trying to do some that should be a basic task that seems to get lost form the books and manuals beginners use.

Written by maclochlainn

April 24th, 2018 at 10:05 pm

Fedora Install unixODBC

without comments

Encountered a problem while running the RODBC library from the R prompt as the root user, as follows:

> install.packages('RODBC')

It failed with the following library dependency:

checking for unistd.h... yes
checking sql.h usability... no
checking sql.h presence... no
checking for sql.h... no
checking sqlext.h usability... no
checking sqlext.h presence... no
checking for sqlext.h... no
configure: error: "ODBC headers sql.h and sqlext.h not found"
ERROR: configuration failed for package ‘RODBC’
* removing ‘/usr/lib64/R/library/RODBC’
 
The downloaded source packages are in
	‘/tmp/RtmpdT1gay/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("RODBC") :
  installation of package ‘RODBC’ had non-zero exit status

I installed unixODBC-devel and unixODBC-gui-qt libraries to fix the library dependencies with the following command as the root user:

yum install -y unixODBC*

It should show you the following when it installs the unixODBC-devel and unixODBC-gui-qt libraries:

Loaded plugins: langpacks, refresh-packagekit
You need to be root to perform this command.
[student@localhost ~]$ su - root
Password: 
Last login: Fri Apr 20 21:18:56 PDT 2018 on pts/1
[root@localhost ~]# yum install -y unixODBC*
Loaded plugins: langpacks, refresh-packagekit
cassandra/signature                                         |  819 B  00:00     
cassandra/signature                                         | 2.9 kB  00:00 !!! 
fedora/20/x86_64/metalink                                   | 3.3 kB  00:00     
mysql-connectors-community                                  | 2.5 kB  00:00     
mysql-tools-community                                       | 2.5 kB  00:00     
mysql56-community                                           | 2.5 kB  00:00     
http://yum.postgresql.org/9.3/fedora/fedora-20-x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
updates/20/x86_64/metalink                                  | 3.1 kB  00:00     
Package unixODBC-2.3.2-4.fc20.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package unixODBC-devel.x86_64 0:2.3.2-4.fc20 will be installed
---> Package unixODBC-gui-qt.x86_64 0:0-0.8.20120105svn98.fc20 will be installed
--> Processing Dependency: libQtNetwork.so.4()(64bit) for package: unixODBC-gui-qt-0-0.8.20120105svn98.fc20.x86_64
--> Processing Dependency: libQtGui.so.4()(64bit) for package: unixODBC-gui-qt-0-0.8.20120105svn98.fc20.x86_64
--> Processing Dependency: libQtCore.so.4()(64bit) for package: unixODBC-gui-qt-0-0.8.20120105svn98.fc20.x86_64
--> Processing Dependency: libQtAssistantClient.so.4()(64bit) for package: unixODBC-gui-qt-0-0.8.20120105svn98.fc20.x86_64
--> Running transaction check
---> Package qt.x86_64 1:4.8.6-30.fc20 will be installed
--> Processing Dependency: qt-common = 1:4.8.6-30.fc20 for package: 1:qt-4.8.6-30.fc20.x86_64
--> Processing Dependency: qt-settings for package: 1:qt-4.8.6-30.fc20.x86_64
---> Package qt-assistant-adp.x86_64 0:4.6.3-6.fc20 will be installed
---> Package qt-x11.x86_64 1:4.8.6-30.fc20 will be installed
--> Processing Dependency: libmng.so.1()(64bit) for package: 1:qt-x11-4.8.6-30.fc20.x86_64
--> Processing Dependency: libclucene.so.3()(64bit) for package: 1:qt-x11-4.8.6-30.fc20.x86_64
--> Running transaction check
---> Package clucene09-core.x86_64 0:0.9.21b-13.fc20 will be installed
---> Package libmng.x86_64 0:1.0.10-12.fc20 will be installed
---> Package qt-common.noarch 1:4.8.6-30.fc20 will be installed
---> Package qt-settings.noarch 0:20-18.fc20 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package              Arch       Version                      Repository   Size
================================================================================
Installing:
 unixODBC-devel       x86_64     2.3.2-4.fc20                 updates      55 k
 unixODBC-gui-qt      x86_64     0-0.8.20120105svn98.fc20     fedora      624 k
Installing for dependencies:
 clucene09-core       x86_64     0.9.21b-13.fc20              updates     300 k
 libmng               x86_64     1.0.10-12.fc20               fedora      166 k
 qt                   x86_64     1:4.8.6-30.fc20              updates     4.7 M
 qt-assistant-adp     x86_64     4.6.3-6.fc20                 fedora      257 k
 qt-common            noarch     1:4.8.6-30.fc20              updates     5.8 k
 qt-settings          noarch     20-18.fc20                   updates      19 k
 qt-x11               x86_64     1:4.8.6-30.fc20              updates      12 M
 
Transaction Summary
================================================================================
Install  2 Packages (+7 Dependent packages)
 
Total download size: 18 M
Installed size: 56 M
Downloading packages:
(1/9): libmng-1.0.10-12.fc20.x86_64.rpm                     | 166 kB  00:01     
(2/9): clucene09-core-0.9.21b-13.fc20.x86_64.rpm            | 300 kB  00:01     
(3/9): qt-4.8.6-30.fc20.x86_64.rpm                          | 4.7 MB  00:00     
(4/9): qt-common-4.8.6-30.fc20.noarch.rpm                   | 5.8 kB  00:00     
(5/9): qt-settings-20-18.fc20.noarch.rpm                    |  19 kB  00:00     
(6/9): qt-assistant-adp-4.6.3-6.fc20.x86_64.rpm             | 257 kB  00:00     
(7/9): qt-x11-4.8.6-30.fc20.x86_64.rpm                      |  12 MB  00:01     
(8/9): unixODBC-devel-2.3.2-4.fc20.x86_64.rpm               |  55 kB  00:00     
(9/9): unixODBC-gui-qt-0-0.8.20120105svn98.fc20.x86_64.rpm  | 624 kB  00:01     
--------------------------------------------------------------------------------
Total                                              4.1 MB/s |  18 MB  00:04     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : libmng-1.0.10-12.fc20.x86_64                                 1/9 
  Installing : qt-settings-20-18.fc20.noarch                                2/9 
  Installing : 1:qt-common-4.8.6-30.fc20.noarch                             3/9 
  Installing : 1:qt-4.8.6-30.fc20.x86_64                                    4/9 
  Installing : clucene09-core-0.9.21b-13.fc20.x86_64                        5/9 
  Installing : 1:qt-x11-4.8.6-30.fc20.x86_64                                6/9 
  Installing : qt-assistant-adp-4.6.3-6.fc20.x86_64                         7/9 
  Installing : unixODBC-gui-qt-0-0.8.20120105svn98.fc20.x86_64              8/9 
  Installing : unixODBC-devel-2.3.2-4.fc20.x86_64                           9/9 
  Verifying  : clucene09-core-0.9.21b-13.fc20.x86_64                        1/9 
  Verifying  : unixODBC-gui-qt-0-0.8.20120105svn98.fc20.x86_64              2/9 
  Verifying  : 1:qt-x11-4.8.6-30.fc20.x86_64                                3/9 
  Verifying  : 1:qt-4.8.6-30.fc20.x86_64                                    4/9 
  Verifying  : qt-settings-20-18.fc20.noarch                                5/9 
  Verifying  : 1:qt-common-4.8.6-30.fc20.noarch                             6/9 
  Verifying  : unixODBC-devel-2.3.2-4.fc20.x86_64                           7/9 
  Verifying  : qt-assistant-adp-4.6.3-6.fc20.x86_64                         8/9 
  Verifying  : libmng-1.0.10-12.fc20.x86_64                                 9/9 
 
Installed:
  unixODBC-devel.x86_64 0:2.3.2-4.fc20                                          
  unixODBC-gui-qt.x86_64 0:0-0.8.20120105svn98.fc20                             
 
Dependency Installed:
  clucene09-core.x86_64 0:0.9.21b-13.fc20                                       
  libmng.x86_64 0:1.0.10-12.fc20                                                
  qt.x86_64 1:4.8.6-30.fc20                                                     
  qt-assistant-adp.x86_64 0:4.6.3-6.fc20                                        
  qt-common.noarch 1:4.8.6-30.fc20                                              
  qt-settings.noarch 0:20-18.fc20                                               
  qt-x11.x86_64 1:4.8.6-30.fc20                                                 
 
Complete!

After installing the unixODBC-devel and unixODBC-gui-qt libraries, I installed the RODBC library from the R prompt, having launched the R environment as the root user:

> install.packages('RODBC')

Installing the RODBC library should install cleanly and generate the following output:

Installing package into ‘/usr/lib64/R/library’
(as ‘lib’ is unspecified)
trying URL 'http://cran.cnr.berkeley.edu/src/contrib/RODBC_1.3-15.tar.gz'
Content type 'application/x-gzip' length 1163967 bytes (1.1 MB)
==================================================
downloaded 1.1 MB
 
* installing *source* package ‘RODBC’ ...
** package ‘RODBC’ successfully unpacked and MD5 sums checked
checking for gcc... gcc -m64 -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -m64 -std=gnu99 accepts -g... yes
checking for gcc -m64 -std=gnu99 option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -m64 -std=gnu99 -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking sql.h usability... yes
checking sql.h presence... yes
checking for sql.h... yes
checking sqlext.h usability... yes
checking sqlext.h presence... yes
checking for sqlext.h... yes
checking for library containing SQLTables... -lodbc
checking for SQLLEN... yes
checking for SQLULEN... yes
checking size of long... 8
configure: creating ./config.status
config.status: creating src/Makevars
config.status: creating src/config.h
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DNDEBUG -I. -I/usr/local/include    -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic  -c RODBC.c -o RODBC.o
gcc -m64 -std=gnu99 -shared -L/usr/lib64/R/lib -Wl,-z,relro -o RODBC.so RODBC.o -lodbc -L/usr/lib64/R/lib -lR
installing to /usr/lib64/R/library/RODBC/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
  converting help for package ‘RODBC’
    finding HTML links ... done
    RODBC-internal                          html  
    RODBC-package                           html  
    odbc                                    html  
    odbcClose                               html  
    odbcConnect                             html  
    odbcDataSources                         html  
    odbcGetInfo                             html  
    odbcSetAutoCommit                       html  
    setSqlTypeInfo                          html  
    sqlColumns                              html  
    sqlCopy                                 html  
    sqlDrop                                 html  
    sqlFetch                                html  
    sqlQuery                                html  
    sqlSave                                 html  
    sqlTables                               html  
    sqlTypeInfo                             html  
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (RODBC)
Making 'packages.html' ... done
 
The downloaded source packages are in/tmp/RtmpdT1gay/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done

I hope that helps anybody who runs into the library dependency problems.

Written by maclochlainn

April 20th, 2018 at 10:43 pm

Fedora R Install

without comments

I’ve started building the new image for the database courses. This one needs to include Oracle, MySQL, Cassandra, Hive, and MongoDB databases; and include examples for C, C++, Java, Perl, PHP, Python, R programming languages.

Installing R was a surprise when I saw how many packages there are for it. It’s a standard yum command from the repository, but it will install 256 packages. The command is:

yum install -y R

Once you install it, you simply start the R interpreter, which is part of the Comprehensive R Archive Network (CRAN). Any installation of the R packages includes CRAN, but there are many additional libraries that you may install.

You can launch the R interpreter by typing the following at the Linux command-line:

R

It will display the following licensing information and then the command prompt:

R version 3.2.0 (2015-04-16) -- "Full of Ingredients"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)
 
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
 
  Natural language support but running in an English locale
 
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
 
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

You have two options for help. As qualified above, you can type help() to get a Linux man page, and q at the colon quits the man page. Typing help.start() launches a browser interface (shown below), which is more helpful.

You can discover your installed R packages with a call to the installed.packages() function but the output lacks clarity and is verbose. You can see a formatted summary of your installed packages with the following command:

print(as.data.frame(installed.packages()[,c(1,3:4)]),row.names=FALSE)

It should display the following:

    Package Version    Priority
       base   3.2.0        base
       boot  1.3-16 recommended
      class  7.3-12 recommended
    cluster   2.0.1 recommended
  codetools  0.2-11 recommended
   compiler   3.2.0        base
   datasets   3.2.0        base
    foreign  0.8-63 recommended
   graphics   3.2.0        base
  grDevices   3.2.0        base
       grid   3.2.0        base
 KernSmooth 2.23-14 recommended
    lattice 0.20-31 recommended
       MASS  7.3-40 recommended
     Matrix   1.2-0 recommended
    methods   3.2.0        base
       mgcv   1.8-6 recommended
       nlme 3.1-120 recommended
       nnet   7.3-9 recommended
   parallel   3.2.0        base
      rpart   4.1-9 recommended
    spatial   7.3-9 recommended
    splines   3.2.0        base
      stats   3.2.0        base
     stats4   3.2.0        base
   survival  2.38-1 recommended
      tcltk   3.2.0        base
      tools   3.2.0        base
      utils   3.2.0        base

The print() function allows us to remove the text-based indexes from display. The indexes would be the same as the package names. If you call frame() function with a second argument of row.names=FALSE, then R converts the text-based indexes to numeric indexes.

You can quit the R environment with the q() or quit() function calls. It will prompt you whether or not you want to save your workspace before you exit.

It’s time to play with R now. I hope this helps you get started by installing and playing with the R programming language.

Written by maclochlainn

April 14th, 2018 at 2:13 pm

How to install MongoDB

without comments

This post shows the yum command to install the MongoDB packages on Linux. More on setup and use will follow.

You install the MongoDB package with the following yum command:

yum install -y mongodb

You should see the following log file, which may also show a missing mirrored site:

Loaded plugins: langpacks, refresh-packagekit
cassandra/signature                                         |  819 B  00:00     
cassandra/signature                                         | 2.9 kB  00:00 !!! 
mysql-connectors-community                                  | 2.5 kB  00:00     
mysql-tools-community                                       | 2.5 kB  00:00     
mysql56-community                                           | 2.5 kB  00:00     
updates/20/x86_64/metalink                                  | 2.6 kB  00:00     
Resolving Dependencies
--> Running transaction check
---> Package mongodb.x86_64 0:2.4.6-1.fc20 will be installed
--> Processing Dependency: v8 for package: mongodb-2.4.6-1.fc20.x86_64
--> Processing Dependency: libv8.so.3()(64bit) for package: mongodb-2.4.6-1.fc20.x86_64
--> Processing Dependency: libtcmalloc.so.4()(64bit) for package: mongodb-2.4.6-1.fc20.x86_64
--> Processing Dependency: libboost_program_options.so.1.54.0()(64bit) for package: mongodb-2.4.6-1.fc20.x86_64
--> Processing Dependency: libboost_iostreams.so.1.54.0()(64bit) for package: mongodb-2.4.6-1.fc20.x86_64
--> Processing Dependency: libboost_filesystem.so.1.54.0()(64bit) for package: mongodb-2.4.6-1.fc20.x86_64
--> Running transaction check
---> Package boost-filesystem.x86_64 0:1.54.0-12.fc20 will be installed
---> Package boost-iostreams.x86_64 0:1.54.0-12.fc20 will be installed
---> Package boost-program-options.x86_64 0:1.54.0-12.fc20 will be installed
---> Package gperftools-libs.x86_64 0:2.1-4.fc20 will be installed
---> Package v8.x86_64 1:3.14.5.10-18.fc20 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package                   Arch       Version                 Repository   Size
================================================================================
Installing:
 mongodb                   x86_64     2.4.6-1.fc20            fedora       30 M
Installing for dependencies:
 boost-filesystem          x86_64     1.54.0-12.fc20          updates      66 k
 boost-iostreams           x86_64     1.54.0-12.fc20          updates      59 k
 boost-program-options     x86_64     1.54.0-12.fc20          updates     147 k
 gperftools-libs           x86_64     2.1-4.fc20              updates     266 k
 v8                        x86_64     1:3.14.5.10-18.fc20     updates     3.0 M
 
Transaction Summary
================================================================================
Install  1 Package (+5 Dependent packages)
 
Total download size: 34 M
Installed size: 101 M
Downloading packages:
(1/6): boost-iostreams-1.54.0-12.fc20.x86_64.rpm            |  59 kB  00:00     
(2/6): boost-filesystem-1.54.0-12.fc20.x86_64.rpm           |  66 kB  00:00     
(3/6): boost-program-options-1.54.0-12.fc20.x86_64.rpm      | 147 kB  00:00     
(4/6): gperftools-libs-2.1-4.fc20.x86_64.rpm                | 266 kB  00:00     
(5/6): v8-3.14.5.10-18.fc20.x86_64.rpm                      | 3.0 MB  00:00     
(6/6): mongodb-2.4.6-1.fc20.x86_64.rpm                      |  30 MB  00:04     
--------------------------------------------------------------------------------
Total                                              7.6 MB/s |  34 MB  00:04     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : 1:v8-3.14.5.10-18.fc20.x86_64                                1/6 
  Installing : boost-program-options-1.54.0-12.fc20.x86_64                  2/6 
  Installing : gperftools-libs-2.1-4.fc20.x86_64                            3/6 
  Installing : boost-filesystem-1.54.0-12.fc20.x86_64                       4/6 
  Installing : boost-iostreams-1.54.0-12.fc20.x86_64                        5/6 
  Installing : mongodb-2.4.6-1.fc20.x86_64                                  6/6 
  Verifying  : boost-iostreams-1.54.0-12.fc20.x86_64                        1/6 
  Verifying  : boost-filesystem-1.54.0-12.fc20.x86_64                       2/6 
  Verifying  : gperftools-libs-2.1-4.fc20.x86_64                            3/6 
  Verifying  : mongodb-2.4.6-1.fc20.x86_64                                  4/6 
  Verifying  : boost-program-options-1.54.0-12.fc20.x86_64                  5/6 
  Verifying  : 1:v8-3.14.5.10-18.fc20.x86_64                                6/6 
 
Installed:
  mongodb.x86_64 0:2.4.6-1.fc20                                                 
 
Dependency Installed:
  boost-filesystem.x86_64 0:1.54.0-12.fc20                                      
  boost-iostreams.x86_64 0:1.54.0-12.fc20                                       
  boost-program-options.x86_64 0:1.54.0-12.fc20                                 
  gperftools-libs.x86_64 0:2.1-4.fc20                                           
  v8.x86_64 1:3.14.5.10-18.fc20                                                 
 
Complete!

Hope this helps those looking for the command.

Written by maclochlainn

September 27th, 2017 at 10:16 pm

Python variable not defined

without comments

While working with a programming example for my students, I ran into an interesting run-time error when I changed their approach to importing Python’s random module. Here’s the raised error message:

Traceback (most recent call last):
  File "windowBouncingBalls.py", line 84, in <module>
    speed = [choice([-2,2]), choice([-2,2])]
NameError: name 'choice' is not defined

You raise the missing choice identifier when two things occur. The first thing requires you to use a standard import statement, like the following example, and the second thing requires you to continue to reference the identifier as “choice“.

import random

You can avoid the error by making the import of random like this:

from random import *

Or, you can leave the ordinary import statement and fully qualify the choice identifier with the random module name, like this:

    speed = [random.choice([-2,2]), random.choice([-2,2])]

As always, I hope this helps those who encounter a similar problem.

Written by maclochlainn

March 27th, 2017 at 12:23 am

Install PyGame on Fedora

without comments

The PyGame library is a wonderful tool for building games with Python. It lets you accomplish a great deal by simply managing events. You need to understand how to use Python functions, modules, and events to build games with this Python library.

You can download and install the PyGame library with the yum utility like this:

yum install -y pygame

It should generate the following list when you install it as the root user:

Loaded plugins: langpacks, refresh-packagekit
Available Packages
pygame.x86_64                        1.9.1-14.fc20                        fedora
[root@localhost ~]# yum install -y pygame
Loaded plugins: langpacks, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package pygame.x86_64 0:1.9.1-14.fc20 will be installed
--> Processing Dependency: numpy for package: pygame-1.9.1-14.fc20.x86_64
--> Processing Dependency: libportmidi.so.0()(64bit) for package: pygame-1.9.1-14.fc20.x86_64
--> Processing Dependency: libSDL_ttf-2.0.so.0()(64bit) for package: pygame-1.9.1-14.fc20.x86_64
--> Processing Dependency: libSDL_mixer-1.2.so.0()(64bit) for package: pygame-1.9.1-14.fc20.x86_64
--> Processing Dependency: libSDL_image-1.2.so.0()(64bit) for package: pygame-1.9.1-14.fc20.x86_64
--> Running transaction check
---> Package SDL_image.x86_64 0:1.2.12-7.fc20 will be installed
---> Package SDL_mixer.x86_64 0:1.2.12-5.fc20 will be installed
--> Processing Dependency: libmikmod for package: SDL_mixer-1.2.12-5.fc20.x86_64
---> Package SDL_ttf.x86_64 0:2.0.11-4.fc20 will be installed
---> Package numpy.x86_64 1:1.8.2-2.fc20 will be installed
--> Processing Dependency: python-nose for package: 1:numpy-1.8.2-2.fc20.x86_64
---> Package portmidi.x86_64 0:217-9.fc20 will be installed
--> Running transaction check
---> Package libmikmod.x86_64 0:3.3.6-3.fc20 will be installed
---> Package python-nose.noarch 0:1.3.0-1.fc20 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package            Arch          Version                  Repository      Size
================================================================================
Installing:
 pygame             x86_64        1.9.1-14.fc20            fedora         2.1 M
Installing for dependencies:
 SDL_image          x86_64        1.2.12-7.fc20            fedora          41 k
 SDL_mixer          x86_64        1.2.12-5.fc20            fedora          91 k
 SDL_ttf            x86_64        2.0.11-4.fc20            fedora          22 k
 libmikmod          x86_64        3.3.6-3.fc20             updates        142 k
 numpy              x86_64        1:1.8.2-2.fc20           updates        3.0 M
 portmidi           x86_64        217-9.fc20               fedora          26 k
 python-nose        noarch        1.3.0-1.fc20             fedora         272 k
 
Transaction Summary
================================================================================
Install  1 Package (+7 Dependent packages)
 
Total download size: 5.7 M
Installed size: 21 M
Downloading packages:
(1/8): SDL_image-1.2.12-7.fc20.x86_64.rpm                   |  41 kB  00:00     
(2/8): SDL_mixer-1.2.12-5.fc20.x86_64.rpm                   |  91 kB  00:00     
(3/8): portmidi-217-9.fc20.x86_64.rpm                       |  26 kB  00:00     
(4/8): SDL_ttf-2.0.11-4.fc20.x86_64.rpm                     |  22 kB  00:00     
(5/8): libmikmod-3.3.6-3.fc20.x86_64.rpm                    | 142 kB  00:00     
(6/8): numpy-1.8.2-2.fc20.x86_64.rpm                        | 3.0 MB  00:02     
(7/8): pygame-1.9.1-14.fc20.x86_64.rpm                      | 2.1 MB  00:01     
(8/8): python-nose-1.3.0-1.fc20.noarch.rpm                  | 272 kB  00:00     
--------------------------------------------------------------------------------
Total                                              1.7 MB/s | 5.7 MB  00:03     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : SDL_ttf-2.0.11-4.fc20.x86_64                                 1/8 
  Installing : SDL_image-1.2.12-7.fc20.x86_64                               2/8 
  Installing : portmidi-217-9.fc20.x86_64                                   3/8 
  Installing : libmikmod-3.3.6-3.fc20.x86_64                                4/8 
  Installing : SDL_mixer-1.2.12-5.fc20.x86_64                               5/8 
  Installing : python-nose-1.3.0-1.fc20.noarch                              6/8 
  Installing : 1:numpy-1.8.2-2.fc20.x86_64                                  7/8 
  Installing : pygame-1.9.1-14.fc20.x86_64                                  8/8 
  Verifying  : pygame-1.9.1-14.fc20.x86_64                                  1/8 
  Verifying  : SDL_mixer-1.2.12-5.fc20.x86_64                               2/8 
  Verifying  : python-nose-1.3.0-1.fc20.noarch                              3/8 
  Verifying  : libmikmod-3.3.6-3.fc20.x86_64                                4/8 
  Verifying  : 1:numpy-1.8.2-2.fc20.x86_64                                  5/8 
  Verifying  : portmidi-217-9.fc20.x86_64                                   6/8 
  Verifying  : SDL_image-1.2.12-7.fc20.x86_64                               7/8 
  Verifying  : SDL_ttf-2.0.11-4.fc20.x86_64                                 8/8 
 
Installed:
  pygame.x86_64 0:1.9.1-14.fc20                                                 
 
Dependency Installed:
  SDL_image.x86_64 0:1.2.12-7.fc20        SDL_mixer.x86_64 0:1.2.12-5.fc20      
  SDL_ttf.x86_64 0:2.0.11-4.fc20          libmikmod.x86_64 0:3.3.6-3.fc20       
  numpy.x86_64 1:1.8.2-2.fc20             portmidi.x86_64 0:217-9.fc20          
  python-nose.noarch 0:1.3.0-1.fc20      
 
Complete!

I hope this helps folks install the software.

Written by maclochlainn

March 25th, 2017 at 1:49 am

Install EasyGUI on Fedora

without comments

The EasyGUI library is a nice tool for developing GUI applications. It doesn’t require you to know event-driven programming to write basic GUI applications because it’s based on Python functions.

You can download and install the EasyGUI library with yum utility like this:

yum install -y python-easygui

It should generate the following list:

Loaded plugins: langpacks, refresh-packagekit
mysql-connectors-community                                  | 2.5 kB  00:00     
mysql-tools-community                                       | 2.5 kB  00:00     
mysql56-community                                           | 2.5 kB  00:00     
pgdg93                                                      | 3.6 kB  00:00     
updates/20/x86_64/metalink                                  | 2.8 kB  00:00     
Resolving Dependencies
--> Running transaction check
---> Package python-easygui.noarch 0:0.96-7.fc20 will be installed
--> Processing Dependency: tkinter for package: python-easygui-0.96-7.fc20.noarch
--> Processing Dependency: python-setuptools for package: python-easygui-0.96-7.fc20.noarch
--> Running transaction check
---> Package python-setuptools.noarch 0:1.4.2-1.fc20 will be installed
---> Package tkinter.x86_64 0:2.7.5-16.fc20 will be installed
--> Processing Dependency: libtk8.5.so()(64bit) for package: tkinter-2.7.5-16.fc20.x86_64
--> Processing Dependency: libtcl8.5.so()(64bit) for package: tkinter-2.7.5-16.fc20.x86_64
--> Processing Dependency: libTix.so()(64bit) for package: tkinter-2.7.5-16.fc20.x86_64
--> Running transaction check
---> Package tcl.x86_64 1:8.5.14-1.fc20 will be installed
---> Package tix.x86_64 1:8.4.3-11.fc20 will be installed
---> Package tk.x86_64 1:8.5.14-1.fc20 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package                 Arch         Version               Repository     Size
================================================================================
Installing:
 python-easygui          noarch       0.96-7.fc20           fedora        481 k
Installing for dependencies:
 python-setuptools       noarch       1.4.2-1.fc20          updates       413 k
 tcl                     x86_64       1:8.5.14-1.fc20       fedora        1.9 M
 tix                     x86_64       1:8.4.3-11.fc20       fedora        253 k
 tk                      x86_64       1:8.5.14-1.fc20       fedora        1.4 M
 tkinter                 x86_64       2.7.5-16.fc20         updates       316 k
 
Transaction Summary
================================================================================
Install  1 Package (+5 Dependent packages)
 
Total download size: 4.7 M
Installed size: 13 M
Downloading packages:
(1/6): python-setuptools-1.4.2-1.fc20.noarch.rpm            | 413 kB  00:00     
(2/6): python-easygui-0.96-7.fc20.noarch.rpm                | 481 kB  00:00     
(3/6): tkinter-2.7.5-16.fc20.x86_64.rpm                     | 316 kB  00:00     
(4/6): tix-8.4.3-11.fc20.x86_64.rpm                         | 253 kB  00:01     
(5/6): tcl-8.5.14-1.fc20.x86_64.rpm                         | 1.9 MB  00:01     
(6/6): tk-8.5.14-1.fc20.x86_64.rpm                          | 1.4 MB  00:03     
--------------------------------------------------------------------------------
Total                                              1.5 MB/s | 4.7 MB  00:03     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : 1:tcl-8.5.14-1.fc20.x86_64                                   1/6 
  Installing : 1:tk-8.5.14-1.fc20.x86_64                                    2/6 
  Installing : 1:tix-8.4.3-11.fc20.x86_64                                   3/6 
  Installing : tkinter-2.7.5-16.fc20.x86_64                                 4/6 
  Installing : python-setuptools-1.4.2-1.fc20.noarch                        5/6 
  Installing : python-easygui-0.96-7.fc20.noarch                            6/6 
  Verifying  : 1:tk-8.5.14-1.fc20.x86_64                                    1/6 
  Verifying  : tkinter-2.7.5-16.fc20.x86_64                                 2/6 
  Verifying  : 1:tix-8.4.3-11.fc20.x86_64                                   3/6 
  Verifying  : 1:tcl-8.5.14-1.fc20.x86_64                                   4/6 
  Verifying  : python-easygui-0.96-7.fc20.noarch                            5/6 
  Verifying  : python-setuptools-1.4.2-1.fc20.noarch                        6/6 
 
Installed:
  python-easygui.noarch 0:0.96-7.fc20                                           
 
Dependency Installed:
  python-setuptools.noarch 0:1.4.2-1.fc20       tcl.x86_64 1:8.5.14-1.fc20      
  tix.x86_64 1:8.4.3-11.fc20                    tk.x86_64 1:8.5.14-1.fc20       
  tkinter.x86_64 0:2.7.5-16.fc20               
 
Complete!

You can then test the EasyGUI library with the following three lines of code inside the IDLE interpreter:

Python 2.7.5 (default, Apr 10 2015, 08:09:05) 
[GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import easygui
>>> flavor = easygui.enterbox("What flavor of bum do you like?")
>>> if easygui.msgbox("You like " + flavor + " gum.") == 'OK':
...   print "OK button clicked ..."
... 
OK button clicked ...

The easygui.enterbox call displays the image below. Enter “Peppermint” in the entry box and click the OK button to assign the “Peppermint” string literal to the flavor variable.

The easygui.msgbox call displays the message below:

When you click the OK button, the program returns an “OK” string to the Python code. It prints the string “OK button clicked …” string:

As always, I hope this helps those looking for instructions and a quick way to play with Python and GUI applications.

Written by maclochlainn

February 22nd, 2017 at 1:35 am

Install cx_Oracle for Python

without comments

This shows you how to install the cx_Oracle library for Python 2.7 on Fedora Linux. If Fedora has it on the server you can download it with the following yum command:

yum install -y cx_Oracle-5.2.1-11g-py27-1.x86_64.rpm

Currently, you’ll get the following failure because it’s not available in the Fedora repository:

Loaded plugins: langpacks, refresh-packagekit
mysql-connectors-community                                      | 2.5 kB  00:00:00     
mysql-tools-community                                           | 2.5 kB  00:00:00     
mysql56-community                                               | 2.5 kB  00:00:00     
pgdg93                                                          | 3.6 kB  00:00:00     
updates/20/x86_64/metalink                                      | 2.3 kB  00:00:00     
No package cx_Oracle-5.2.1-11g-py27-1.x86_64.rpm available.
Error: Nothing to do

You can download the cx_Oracle library from the Python web site. The cx_Oracle documentation qualifies module interfaces, objects, and connections. Assuming your Linux user’s name is student, you download the cx_Oracle library into the /home/student/Downloads directory. Then, you use the su or sudo command to become the root user.

As the root user, run the following yum command:

yum install -y ~student/Downloads/cx_Oracle-5.2.1-11g-py27-1.x86_64.rpm

You should see the following output:

Loaded plugins: langpacks, refresh-packagekit
Examining /home/student/Downloads/cx_Oracle-5.2.1-11g-py27-1.x86_64.rpm: cx_Oracle-5.2.1-1.x86_64
Marking /home/student/Downloads/cx_Oracle-5.2.1-11g-py27-1.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package cx_Oracle.x86_64 0:5.2.1-1 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=======================================================================================
 Package        Arch        Version      Repository                               Size
=======================================================================================
Installing:
 cx_Oracle      x86_64      5.2.1-1      /cx_Oracle-5.2.1-11g-py27-1.x86_64      717 k
 
Transaction Summary
=======================================================================================
Install  1 Package
 
Total size: 717 k
Installed size: 717 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : cx_Oracle-5.2.1-1.x86_64                                            1/1 
  Verifying  : cx_Oracle-5.2.1-1.x86_64                                            1/1 
 
Installed:
  cx_Oracle.x86_64 0:5.2.1-1                                                           
 
Complete!

After you install the cx_Oracle-5.2.1-1.x86_64 package, you can find the installed files with this rpm command:

rpm -ql cx_Oracle-5.2.1-1.x86_64

It lists:

/usr/lib64/python2.7/site-packages/cx_Oracle-5.2.1-py2.7.egg-info
/usr/lib64/python2.7/site-packages/cx_Oracle-5.2.1-py2.7.egg-info/PKG-INFO
/usr/lib64/python2.7/site-packages/cx_Oracle-5.2.1-py2.7.egg-info/SOURCES.txt
/usr/lib64/python2.7/site-packages/cx_Oracle-5.2.1-py2.7.egg-info/dependency_links.txt
/usr/lib64/python2.7/site-packages/cx_Oracle-5.2.1-py2.7.egg-info/top_level.txt
/usr/lib64/python2.7/site-packages/cx_Oracle.so
/usr/share/doc/cx_Oracle-5.2.1
/usr/share/doc/cx_Oracle-5.2.1/BUILD.txt
/usr/share/doc/cx_Oracle-5.2.1/README.txt
/usr/share/doc/cx_Oracle-5.2.1/samples
/usr/share/doc/cx_Oracle-5.2.1/samples/DatabaseChangeNotification.py
/usr/share/doc/cx_Oracle-5.2.1/samples/DatabaseShutdown.py
/usr/share/doc/cx_Oracle-5.2.1/samples/DatabaseStartup.py
/usr/share/doc/cx_Oracle-5.2.1/samples/ReturnLongs.py
/usr/share/doc/cx_Oracle-5.2.1/samples/ReturnUnicode.py
/usr/share/doc/cx_Oracle-5.2.1/samples/RowsAsInstance.py
/usr/share/doc/cx_Oracle-5.2.1/test
/usr/share/doc/cx_Oracle-5.2.1/test/3kArrayDMLBatchError.py
/usr/share/doc/cx_Oracle-5.2.1/test/3kNumberVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/3kStringVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/ArrayDMLBatchError.py
/usr/share/doc/cx_Oracle-5.2.1/test/BooleanVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/Connection.py
/usr/share/doc/cx_Oracle-5.2.1/test/Cursor.py
/usr/share/doc/cx_Oracle-5.2.1/test/CursorVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/DateTimeVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/IntervalVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/LobVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/LongVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/NCharVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/NumberVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/ObjectVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/SessionPool.py
/usr/share/doc/cx_Oracle-5.2.1/test/SetupTest.sql
/usr/share/doc/cx_Oracle-5.2.1/test/StringVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/TestEnv.py
/usr/share/doc/cx_Oracle-5.2.1/test/TimestampVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/test.py
/usr/share/doc/cx_Oracle-5.2.1/test/test3k.py
/usr/share/doc/cx_Oracle-5.2.1/test/test_dbapi20.py
/usr/share/doc/cx_Oracle-5.2.1/test/uArrayDMLBatchError.py
/usr/share/doc/cx_Oracle-5.2.1/test/uConnection.py
/usr/share/doc/cx_Oracle-5.2.1/test/uCursor.py
/usr/share/doc/cx_Oracle-5.2.1/test/uCursorVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/uDateTimeVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/uIntervalVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/uLobVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/uLongVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/uNumberVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/uObjectVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/uSessionPool.py
/usr/share/doc/cx_Oracle-5.2.1/test/uStringVar.py
/usr/share/doc/cx_Oracle-5.2.1/test/uTimestampVar.py

After you installed the software, you can test whether inside Python’s IDLE environment with the import command, like this:

Python 2.7.5 (default, Apr 10 2015, 08:09:05) 
[GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: libclntsh.so.11.1: cannot open shared object file: No such file or directory

This error indicates that Oracle Client software isn’t installed, which is true in this case. I only installed the Oracle Database 11g Express Edition. You need to download the Oracle Client software and install it as the root user.

You download the Oracle Client software from the Oracle web site. Assuming your Linux user’s name is student, you download the cx_Oracle library into the /home/student/Downloads directory. Then, you use the su or sudo command to become the root user.

As the root user, run the following yum command:

yum install -y ~student/Downloads/oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm

You should see the following output:

Loaded plugins: langpacks, refresh-packagekit
Examining /home/student/Downloads/oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm: oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64
Marking /home/student/Downloads/oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package oracle-instantclient11.2-basic.x86_64 0:11.2.0.4.0-1 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package
        Arch   Version
                      Repository                                           Size
================================================================================
Installing:
 oracle-instantclient11.2-basic
        x86_64 11.2.0.4.0-1
                      /oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64 179 M
 
Transaction Summary
================================================================================
Install  1 Package
 
Total size: 179 M
Installed size: 179 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64           1/1 
  Verifying  : oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64           1/1 
 
Installed:
  oracle-instantclient11.2-basic.x86_64 0:11.2.0.4.0-1                          
 
Complete!

You can create a Python program that checks your ability to connect to the Oracle database, like the following oracleConnection.py file:

# Import the Oracle library.
import cx_Oracle
 
try:
  # Create a connection.
  db = cx_Oracle.connect("student/student@xe")
 
  # Print a message.
  print "Connected to the  Oracle " + db.version + " database."
 
except cx_Oracle.DatabaseError, e:
  error, = e.args
  print >> sys.stderr, "Oracle-Error-Code:", error.code
  print >> sys.stderr, "Oracle-Error-Message:", error.message
 
finally:
  # Close cursor. 
  db.close()

You can run this from the Linux command line with the following syntax:

python oracleConnection.py

It should return the following string:

Connected to the Oracle 11.2.0.2.0 database.

Now, you can create a Python program that reads data from the Oracle database. The following oracleString.py file reads a string literal from the pseudo table dual:

# Import the Oracle library.
import cx_Oracle
 
try:
  # Create a connection.
  db = cx_Oracle.connect("student/student@xe")
 
  # Create a cursor.
  cursor = db.cursor()
 
  # Execute a query.
  cursor.execute("SELECT 'Hello world!' FROM dual")
 
  # Read the contents of the cursor.
  for row in cursor:
    print (row[0]) 
 
except cx_Oracle.DatabaseError, e:
  error, = e.args
  print >> sys.stderr, "Oracle-Error-Code:", error.code
  print >> sys.stderr, "Oracle-Error-Message:", error.message
 
finally:
  # Close cursor and connection. 
  cursor.close()
  db.close()

You can run this from the Linux command line with the following syntax:

python oracleString.py

It should return the following string:

Hello world!

Now, you can create a Python program that reads actual table data from the Oracle database (assuming you have a copy of my video store database). The following oracleTable.py file reads a string literal from the pseudo table dual:

# Import the Oracle library.
import cx_Oracle
 
try:
  # Create a connection.
  db = cx_Oracle.connect("student/student@xe")
 
  # Create a cursor.
  cursor = db.cursor()
 
  # Execute a query.
  cursor.execute("SELECT item_title, item_subtitle FROM item")
 
  # Read the contents of the cursor.
  for row in cursor:
    print (row[0], row[1]) 
 
except cx_Oracle.DatabaseError, e:
  error, = e.args
  print >> sys.stderr, "Oracle-Error-Code:", error.code
  print >> sys.stderr, "Oracle-Error-Message:", error.message
 
finally:
  # Close cursor and connection. 
  cursor.close()
  db.close()

You can run this from the Linux command line with the following syntax:

python oracleTable.py

It should return the following strings (only a subset of the returned values):

("Harry Potter and the Sorcer's Stone", 'Two-Disc Special Edition')
('Harry Potter and the Chamber of Secrets', 'Two-Disc Special Edition')
('Harry Potter and the Prisoner of Azkaban', 'Two-Disc Special Edition')
('Harry Potter and the Chamber of Secrets', None)
('Harry Potter and the Goblet of Fire', 'Widescreen Edition')
('Harry Potter and the Goblet of Fire', 'Two-Disc Special Edition')
('Harry Potter and the Order of the Phoenix', 'Widescreen Edition')
('The Lord of the Rings - Fellowship of the Ring', 'Widescreen Edition')
('The Lord of the Rings - Fellowship of the Ring', 'Platinum Series Special Extended Edition')
('The Lord of the Rings - Two Towers', 'Widescreen Edition')
('The Lord of the Rings - Two Towers', 'Platinum Series Special Extended Edition')
('The Lord of the Rings - The Return of the King', 'Widescreen Edition')
('The Lord of the Rings - The Return of the King', 'Platinum Series Special Extended Edition')
('Star Wars - Episode I', 'The Phantom Menace')
('Star Wars - Episode II', 'Attack of the Clones')
('Star Wars - Episode III', 'Revenge of the Sith')
('Star Wars - Episode IV', 'A New Hope')
('Star Wars - Episode V', 'The Empire Strikes Back')
('Star Wars - Episode VI', 'Return of the Jedi')

As always, I hope this helps others who want to work with Python and the Oracle database.

Written by maclochlainn

October 19th, 2016 at 1:47 am

Oracle Segment Fails

with 2 comments

The instance that I’ve built for my students in a Fedora VM is quite stable except for one feature. The feature is the hibernation process of the base operating system. Sometimes when the base operating system hibernates, it causes the Oracle shared memory segment to fail. When that happens you get the following error:

ERROR:
ORA-01034: ORACLE NOT available
ORA-27101: shared memory realm does NOT exist
Linux-x86_64 Error: 2: No such FILE OR DIRECTORY
Process ID: 0
SESSION ID: 0 Serial NUMBER: 0

I created the master sudoer account as the student user. The oracle user is configured so that you can’t log in to the Linux OS with it. To restart the instance you can do the following in a default Oracle 11g XE installation:

su - root

or, you can do this:

sudo sh

Then as the root user, you can sign on to the oracle user’s account by using the su command without a password, like:

su - oracle

As the user who installed the Oracle instance, you can connect to the database without a password after you source the environment file. The standard Oracle 11g XE environment file can be sources like this:

. /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh

Alternatively, for my students there is a .bashrc file that they can manually source. It contains the following:

# Source global definitions
if [ -f /etc/bashrc ]; then
  . /etc/bashrc
fi
 
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
 
# User specific aliases and functions
. /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
 
# Wrap sqlplus with rlwrap to edit prior lines with the
# up, down, left and right keys.
sqlplus () 
{
    # Discover the fully qualified program name. 
    path=`which rlwrap 2>/dev/null`
    file=''
 
    # Parse the program name from the path.
    if [ -n ${path} ]; then
        file=${path##/*/}
    fi;
 
    # Wrap when there is a file and it is rewrap.
    if [ -n ${file} ] && [[ ${file} = "rlwrap" ]]; then
        rlwrap sqlplus "${@}"
    else
        echo "Command-line history unavailable: Install the rlwrap package."
        $ORACLE_HOME/bin/sqlplus "${@}"
    fi
}
 
# Set vi as a command line editor.
set -o vi

You can source the oracle user’s .bashrc account, like this:

. .bashrc

After you’ve sourced the environment, you can connect as the internal user with the following syntax:

sqlplus / AS sysdba

Connected as the internal user, run these two commands in sequence:

shutdown IMMEDIATE
startup

Then, you should be able to connect as the student user or another ordinary user with the following syntax:

CONNECT student/student

Hope this helps my students and those who want to know how to restart the Oracle instance.

Written by maclochlainn

October 16th, 2016 at 10:29 pm

Can’t Display 256 Colors

without comments

If you’re reading this post, you most likely are trying to run the Oracle Database 11g or 12c runInstaller program, and it’s failing a critical dependency check and displaying an error like the one below. If so, choose n because if you choose y it won’t launch the Oracle Installer.

Starting Oracle Universal Installer...
 
Checking Temp space: must be greater than 500 MB.   Actual 30824 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 3967 MB    Passed
Checking monitor: must be configured to display at least 256 colors
    >>> Could not execute auto check for display colors using command /usr/bin/xdpyinfo. Check if the DISPLAY variable is set.    Failed <<<<
 
Some requirement checks failed. You must fulfill these requirements before
 
continuing with the installation,
 
Continue? (y/n) [n] n

The first thing to check is whether you’ve the $TERM environment variable. It’ll be set in your env list but may not be set in your .bashrc file. You can see whether it’s set by running the following command:

echo $TERM

It should return a value, like this:

xterm-256color

If you didn’t get that value, use the env command to lookup the $TERM. The correct value can be found by running the env command like this:

env | grep -i term

Add $TERM environment variable to your .bashrc file and source it after the change or reboot the user’s session:

export TERM=xterm-256color

If it still doesn’t work, some posts ask you to run xclock but you don’t generally install the xhost clients. Those articles assumes you’ve installed the xorg-x11-apps package library. That’s more or less a choice you made when installing the Linux OS. You can check for the presence of the library with the following command as the root user:

rpm -qa xorg-x11-apps

If the command fails to return a result from the search of Red Hat Package Manager (RPM) libraries, you haven’t installed it. You can install it as the root superuser with this syntax:

yum install -y xorg-x11-apps

It should display the following result when successful:

Loaded plugins: langpacks
Resolving Dependencies
--> Running transaction check
---> Package xorg-x11-apps.x86_64 0:7.7-6.el7 will be installed
--> Processing Dependency: libXaw.so.7()(64bit) for package: xorg-x11-apps-7.7-6.el7.x86_64
--> Running transaction check
---> Package libXaw.x86_64 0:1.0.12-5.el7 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=================================================================================
 Package              Arch          Version              Repository         Size
=================================================================================
Installing:
 xorg-x11-apps        x86_64        7.7-6.el7            ol7_latest        304 k
Installing for dependencies:
 libXaw               x86_64        1.0.12-5.el7         ol7_latest        190 k
 
Transaction Summary
=================================================================================
Install  1 Package (+1 Dependent package)
 
Total download size: 494 k
Installed size: 1.2 M
Downloading packages:
(1/2): libXaw-1.0.12-5.el7.x86_64.rpm                     | 190 kB  00:00:00     
(2/2): xorg-x11-apps-7.7-6.el7.x86_64.rpm                 | 304 kB  00:00:00     
---------------------------------------------------------------------------------
Total                                            690 kB/s | 494 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libXaw-1.0.12-5.el7.x86_64                                    1/2 
  Installing : xorg-x11-apps-7.7-6.el7.x86_64                                2/2 
  Verifying  : libXaw-1.0.12-5.el7.x86_64                                    1/2 
  Verifying  : xorg-x11-apps-7.7-6.el7.x86_64                                2/2 
 
Installed:
  xorg-x11-apps.x86_64 0:7.7-6.el7                                               
 
Dependency Installed:
  libXaw.x86_64 0:1.0.12-5.el7                                                   
 
Complete!

After installing the xorg-x11-apps library packages, you can retry running the Oracle installer. You should now see the following successful message set:

Starting Oracle Universal Installer...
 
Checking Temp space: must be greater than 500 MB.   Actual 30809 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 3967 MB    Passed
Checking monitor: must be configured to display at least 256 colors.    Actual 16777216    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2016-06-01_01-50-54AM. Please wait ...

As always, I hope this helps my students and anybody looking for a solution to a less than explicit error message.

Written by maclochlainn

June 1st, 2016 at 2:12 am