ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Python Installation Issue And Resolution On Redhat Linux.

Updated on August 26, 2015

Your first step to learn Python is to get it installed. Though it’s easy to install python on UNIX And now days most of latest Linux Operating Systems comes with default python. But if you are intended to high level python programming then you need to add some additional packages, tools or libraries. That need upgrade or re-install a fresh instance for higher version of python. During update or re-install, process, you may encounter installation issues at an extent. I am attempting to endeavor a list of such issues and deliver possible resolution, to identify and fix these problem easily and quickly.

1. Download Python by using "wget" command.

You can get security certificate issue to download by wget option, for SSL network and for https (Secure) link. If you are installing python from https://www.python.org/ftp/python/2.4.6/Python-2.4.6.tar.bz2, you will get error;

“Unable to establish SSL connection” to resolve this issue you need to use wget command with “–no-check” option.

Error message:
[root@linpuba166 bin]# wget https://www.python.org/ftp/python/2.4.6/Python-2.4.6.tar.bz2 --2015-09-08 13:37:46-- https://www.python.org/ftp/python/2.4.6/Python-2.4.6.tar.bz2 Resolving www.python.org... 23.235.40.223 onnecting to www.python.org|23.235.40.223|:443... connected. ERROR: cannot verify www.python.org's certificate, issued by `/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 Extended Validation Server CA': Unable to locally verify the issuer's authority. To connect to www.python.org insecurely, use `--no-check-certificate'.
 Unable to establish SSL connection.

Resolution

Use wget with Option "--no-Check". This will allow, to Download without check for secure connection.
"wget https://www.python.org/ftp/python/2.4.6/Python-2.4.6.tar.bz2 --no-check"

2. Wrong (older) python version is displayed.

Older python version is displayed for command,
"$python -V" and "$which python"

One of the most common error "You installed python version 3* (any later version) and set environment PATH for current version. But your python installation is showing older (previous) version.

Say for example, I had installed newr version of python (3.4.3) and set path for current version. Still my default python version is displayed as "2.4.6", older version of python.

$which python
/usr/bin/python2.4.6

python -V
Python 2.4.6

python3 -V
Python 3.4.3

Resolution

You need to check for default python path entry from PATH and startup files like bashrc and profile. Any from these 3 could be the possible reason,

  • System PATH is not set correctly.
  • bashrc or profile files contains previous python path.
  • Previous installed python path hard linked for python library file.

  • Reset System PATH.

Find the correct path for (newer) python and (Say, path for required default python version is "/PATH"), then command to set path is,

$ export PATH=”echo$PATH”:/PATH

  • System start-up or profile has previous path.

Your current python path to system startup file. You can edit that manually or use below command. Say my current python path is "/opt/python3,4/bin", then command will be -

echo 'export PATH="$PATH:/opt/python3.4.3/bin"' >> ~/.bashrc
echo 'export PATH="$PATH:/opt/python3.4.3/bin"' >> ~/.profile
export PYTHONDOCS=/usr/share/doc/python-3.4.3/html

To update PATH manually,

$vi ~/.bashrc
#Add python PATH in file,
PATH="$PATH:/opt/python3.4.3/bin

vi ~/.profile
#Add python PATH in file,
PATH="$PATH:/opt/python3.4.3/bin

3. Can't update newer (later) python details for, $which python.

Updated correct path for Python to System $PATH and updated profile and bashrc files .
But command “$which python, is still showing older python version.

Resolution

You need to check 2 most possible scenarios to fix this issue,

  • Possibly your system PATH has entry for both versions of python. Where first entry is for older version of python.
  • You have hard/soft linked path of old python to default python.

Update Path: For example. If you had installed python at path, /opt/python3.4.3/ then you can update path by commands,

echo 'export PATH=opt/python3.4.3/bin:”$PATH”
echo 'export PATH="$PATH:/opt/python3.4.3/bin"' >> ~/.bashrc
echo 'export PATH="$PATH:/opt/python3.4.3/bin"' >> ~/.profile

Remove hard/soft link: If you had created any hardlnik to "/bin/local/ python" then unlink that.

4: Issue to upgrade python.

If you are getting error "this system is not registered with RHN" , while upgrading python. You need to register with command "rhn_register".

$yum upgrade python
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Skipping security plugin, no data
Setting up Upgrade Process
No Packages marked for Update

Resolution

You need to register RHN, by command,

  • $rhn_register
  • $yum list update
  • $yum update

5: Yum update fails with error "No more mirrors to try".

Error

yum update fails with the error : [Errno 256] No more mirrors to try
yum update fails with :-Raw
Error Downloading Packages:
InstallMedia: [Errno 256] 
No more mirrors to try.

Resolution

Seems your system is not registered with RHN Classic. If the system is registered to RHN Classic, only rhel-source.repo should be present under /etc/yum.repos.d/. you need remove any local repositories, or any other media repositories.

Check if system is registered with RHN Classic,
$cd /etc/yum.repos.d/ | ls rhel-source | wc –l

OUTPUT:
This should result 1, If – system is registered with RHN Classic. Else output will be 0.
If system is registered with RHN Classic then you shouldn’t get this error. If system is not registered with RHN Classic then you need to check and remove all other local repositories.

Check and remove, if any other local repository present,

$cd //etc/yum.repos.d/ | ls .* | wc –l
OUTPUT: If output of above command is >1, Then you need to remove all local repository files.

Remove local repository by <repository name>, and old yum cache from system
$rm -rf /etc/yum.repos.d/<lrepository name>
$rm -fr /var/cache/yum/*
$yum clean all

List the valid repositories $yum repolist This should resolve the issue, you may gey more details from Redhat support site: "https://access.redhat.com/solutions/203603".

6: Issue to remove Python files and directories for older (default) python version.

Uninstalled python by command,
$yum uninstall python

Resolution

If previous python instance was installed bu easy_install method. Then yum uninstall will not remove some of the files. You need to remove them. Follow these steps to remove older files.
[consider example commands to remove older version 2.4, you need to replace the version with the version observed in your system]].

find . -name "python*" -exec rm -rf {} \;
find . -name "pip*" -exec rm -rf {} \;

$rm -f /usr/local/bin/python2.4*
$rm -f /usr/local/bin/pip2.4*
$rm -f /usr/local/bin/pydoc
$rm -rf /usr/local/bin/include/python2.4*
$rm -f /usr/local/lib/libpython2.4*.a
$rm -rf /usr/local/lib/python2.4*
$rm -f /usr/local/share/man/python2.4*.1
$rm -rf /usr/local/lib/pkgconfig
$rm -f /usr/local/bin/idle
$rm -f /usr/local/bin/easy_install-2.4*

7: Yum Command Not Working.

Error:

$yum
"-bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory". 
 OR
 " -bash: yum: command not found".
 OR
 "-bash: /usr/bin/yum: No such file or directory".

$yum --version
There was a problem importing one of the Python modules required to run yum. The error leading to this problem was:
No module named yum
Please install a package which provides this module, or verify that the module is installed correctly.
It's possible that the above module doesn't match the current version of Python, which is:
2.6.6 (r266:84292, Nov 21 2013, 10:50:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]
If you cannot solve this problem yourself, please go to
the yum faq at:  http://yum.baseurl.org/wiki/Faq

There are couple of scenarios when you can face this issue,

  • You uninstalled default python or somehow default python is corrupted and no any other python instance is available in your system. You know, to run yum one python modules is required.
  • Wrong hard/soft linke is created for “/usr/bin/python”. OR no link is created. [Issue with python environment set].
  • Yet another possible reason is linked path doesn’t have specific files (say some files missing/deleted or corrupted from linked folder).
  • In case if, Somehow Yum got corrupted.
  • And most tricky situation to resolve, you created hard link to python files by different user (Not as a root user). Other user doesn’t have all root (+X) permissions.

Likewise, Many other scenarios are thinkable.So, now the question - how to resolve this issue?

Resolution

If somehow “yum” got corrupted, then re-installation of yum will resolve the issues:

  • -bash: yum: command not found".
  • -bash: /usr/bin/yum: No such file or directory.
You need to download “yum”and reinstall as: (an example below to download and re-install yum version 3.4.3, you may select any other listed),


$wget http://yum.baseurl.org/download/3.4/yum-3.4.3.tar.gz
$tar –xvf yum-3.4.3.tar.gz
$cd yum-3.4.3
$./configure
$make
$make install

  • Check symb link, if that is pointing your correct python path.

In case of error, " -bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory". You need to check if location of installed python is correct.

Scenario: Usually this happen, when you have two different versions of python and both instances are installed at different locations.
And If you uninstall default python version and install a new python at location say: /usr/local/bin/python.
If your default python instance was installed at location: /usr/bin/python
Then Issue will be: -bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory.

You need to change the path for python (Symb link) to current python path and unlink previous symb link.That will resolve this error,

Hope your issue is resolved and you found this article, worthwhile to resolve your query and issue.

Was this article helpful to resolve your query?

See results

Comments

    0 of 8192 characters used
    Post Comment

    No comments yet.

    working

    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://hubpages.com/privacy-policy#gdpr

    Show Details
    Necessary
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
    Features
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Marketing
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Statistics
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)