0

I'm trying to install Python (just assumed use the latest version, 3.5.1) on Red Hat Linux. Somehow the standard library is not getting installed, I also can't use pip. I'm pretty new to Linux, so it's entirely possible I'm making a really stupid mistake.

My installation has been (what I think is standard)

./configure
make
make install

which runs fine. Then I was using a symbolic link to have 'python' point to the new install, something similar to

ln -sf /usr/local/bin/python3.5 /usr/bin/python

which seemed to work, because entering

python --version

returned 3.5.1 correctly.

So what am I doing wrong? Why does my install seem to lack the standard library?

To clarify the reason that I suspect that the standard library isn't installed, what happened is that I tried to use pip and discovered it wasn't installed, so attempting to install it using the get-pip.py file I received a message that zlib not available.

BenI
  • 162
  • 5
  • 1
    You can't use the package manager? Like, `yum install python`? – OneCricketeer Feb 28 '16 at 00:05
  • 5
    What exactly is it that's not working for you? – Murphy Feb 28 '16 at 00:16
  • 1
    Have you checked your install path? What's your `$PYTHONPATH`, `$PYTHONHOME` and `sys.prefix` look like? – ffledgling Feb 28 '16 at 00:21
  • 1
    Your link names seem bogus. The file systems usually used with Linux are case-sensitive so `Python` and `python` are not the same thing. – 5gon12eder Feb 28 '16 at 00:30
  • typing yum install python gives a SyntaxError. I am running Red Hat 6.7 btw – BenI Feb 28 '16 at 00:50
  • @BenI that's because you've messed up your python install and yum uses python under the hood. – ffledgling Feb 28 '16 at 00:50
  • I'm not sure how to check the `$PYTHONPATH`, `$PYTHONHOME` and `sys.prefix` – BenI Feb 28 '16 at 00:55
  • `echo $PYTHONPATH`, `echo $PYTHONHOME` `python -c 'import sys; print(sys.prefix)'` in your terminal. – ffledgling Feb 28 '16 at 00:58
  • `sys.prefix` gives /usr/local . `echo $PYTHONPATH` and `echo $PYTHONHOME` return nothing – BenI Feb 28 '16 at 01:02
  • Please don't install things globally (like in `/usr/bin`) without understanding WTF you're doing. You **will** screw up your system, *guaranteed*. Install in your `$HOME`, make `~/bin`, and add it to the front of your `$PATH`. From your lack of mention of `sudo`, you're probably logged in as `root`, too. Make a regular user and *use it*. – MattDMo Feb 28 '16 at 02:42

1 Answers1

3

Looks like you have a missing zlib.

It would be nice to check if you have the other standard library modules, such as random, collections etc. installed.

When building python from source, you need to specifically configure and compile python with zlib.

This answer explains how to do it, quoting from it:

  • Install the appropriate Zlib-dev package. For example on Ubuntu it is called zlib1g-dev. This will provide the zlib.h include file.

  • After compiling your python sources run the configure script: ./configure –with-zlib=/usr/include

  • Now make and make install should work.

Another similar question

As a side note, over-writing your standard python2 install with python3 is not the smartest of moves on a RHEL family operating system. It will probably break yum at the very least and bork your box in the worst case.

Community
  • 1
  • 1
ffledgling
  • 11,502
  • 8
  • 47
  • 69