LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Python 2.6 - cannot figure out how to get it to find its own library files (http://www.linuxquestions.org/questions/linux-newbie-8/python-2-6-cannot-figure-out-how-to-get-it-to-find-its-own-library-files-761789/)

rylan76 10-14-2009 05:35 AM

Python 2.6 - cannot figure out how to get it to find its own library files
 
Hi Guys

I've compiled and installed Python 2.6 using the following configure line:

Code:

[rylan@development Python-2.6.3]$ ./configure --enable-pth --enable-shared
Python compiles and installs fine afterward. I've confirmed that the files go into /usr/local/lib and /usr/local/bin:

Code:

[root@development bin]# ls python* -l
-rwxr-xr-x 2 root root 7767 Oct 14 12:11 python
-rwxr-xr-x 2 root root 7767 Oct 14 12:11 python2.6
-rwxr-xr-x 1 root root 1424 Oct 14 12:12 python2.6-config
lrwxrwxrwx 1 root root  16 Oct 14 12:12 python-config -> python2.6-config
[root@development bin]#  cd /usr/loca/lib/python2.6/
[root@development python2.6]# pwd
/usr/local/lib/python2.6
[root@development python2.6]#

I've symlinked /usr/lib/python2.6 to /usr/local/lib/python2.6:

Code:

[root@development lib]# ln -s /usr/local/lib/python2.6/ python2.6
[root@development lib]# ls python2.6 -l
lrwxrwxrwx 1 root root 25 Oct 14 12:26 python2.6 -> /usr/local/lib/python2.6/
[root@development lib]#

Furthermore, I've ensured that PYTHONPATH and PYTHONHOME are set correctly in my .bashrc:

Code:

export PYTHONPATH=usr/local/lib/python2.6
export PYTHONHOME=usr/local/lib/python2.6

[rylan@development ~]$ set | grep PYTHON
PYTHONHOME=usr/local/lib/python2.6
PYTHONPATH=usr/local/lib/python2.6
[rylan@development ~]$

HOWEVER

Python still does not find its files:

Code:

[rylan@development ~]$ python
'import site' failed; use -v for traceback
Python 2.6.3 (r263, Oct 14 2009, 12:08:21)
[GCC 4.1.1 20061011 (Red Hat 4.1.1-30)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

I. e.
Quote:

'import site' failed; use -v for traceback
keeps on occurring. I've reinstalled twice, removed the .bashrc entries, nothing at all helps. I just keep on getting "import site failed" messages.

Also, this of course means I cannot run any worthwhile python scripts. I'm trying to get scons going, but of course it won't work 'cause python cannot find "itself":

Code:

[rylan@development scons-1.2.0]$ python setup.py install
'import site' failed; use -v for traceback
Traceback (most recent call last):
  File "setup.py", line 26, in <module>
    import os
ImportError: No module named os
[rylan@development scons-1.2.0]$

How can I get python 2.6 to "find itself" on my system? I'm running FC6. (This doesn't work on my FC11 system at home either, with exactly the same problems.)

ANY help appreciated!

Thanks,

tredegar 10-14-2009 12:00 PM

Python is not my thing, but it is installed on my system (I just used my distro's package manager to install it) and it works.

You keep getting the error notification "'import site' failed; use -v for traceback"

So why haven't you tried python -v ? Maybe that'll help you find whatever is missing, otherwise post the output here and some python guru will probably appear.

lutusp 10-14-2009 04:38 PM

Quote:

Originally Posted by rylan76 (Post 3718679)
Hi Guys

I've compiled and installed Python 2.6 using the following configure line:


[ snip ]

I've reinstalled twice, removed the .bashrc entries, nothing at all helps. I just keep on getting "import site failed" messages.

Also, this of course means I cannot run any worthwhile python scripts. I'm trying to get scons going, but of course it won't work 'cause python cannot find "itself":

[ snip ]

ANY help appreciated!

Thanks,

Here is a recipe to solve the problem:

1. Run the machine that has Fedora 11, just because you can use yum and can reasonably expect up-to-date archive content.

2. Install Python properly:

# yum install python

Suddenly everything will work, without any special variable settings or library manipulation. Experience shock and disorientation.

3. Scratch you head, ruminate, walk around in circles.

4. Decide to upgrade to Fedora 11 on both machines.

Done.

rylan76 10-16-2009 01:22 AM

Tee hee hee fanx.... yep I was coming to that conclusion myself (and it does, in fact, work fine on FC 11 anyway - after ensuring the paths were correctly setup...!)

Seems I -did- have an older python on the FC6 machine at work, and it has somehow messed up the new Python install.

Anyway, will try it out this afternoon at home on FC11.

Thanks for the replies!


All times are GMT -5. The time now is 02:23 AM.