1

calling pydoc file is returning, bad interpreter. no such file or directory.

There's a workaround by calling it like python -m pydoc file.

I would love to understand the way the links work better. For example what does the following do?

sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc /usr/bin/pydoc
- which one is linking to which?

I'm running version 2.7 and pydoc exists in the /usr/bin/, as do pydoc2.5 and pydoc2.6. Same issue with python-config, which also exists in 2.5 and 2.6 versions.

Thanks a lot for any insight.

Here's how problem was solved, based on correct answer below:

Apparently whatever i had under pydoc2.7 was not the right thing. Thanks a lot for explaining how links work!

MatthewMartin
  • 32,326
  • 33
  • 105
  • 164
MikeiLL
  • 6,282
  • 5
  • 37
  • 68
  • `ln -s ` creates a `` that points to the ``. In your example, the `ln -s` command creates a file `/usr/local/pydoc` that links to `/System/Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc`. – huu May 16 '14 at 05:10
  • @HuuNguyen - this comment should be an answer - you might want to expand it a bit. – Tony Suffolk 66 May 16 '14 at 05:17
  • thank you, @HuuNguyen. so i'm guessing that the `pydoc` i'm seeing in `/urs/bin/` is a link, and that pydoc simply doesn't exist in `/System/Library.../2.7/bin`. I'll see if I can find it and copy or move it there and post result. – MikeiLL May 16 '14 at 13:11

1 Answers1

1

The command:

sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc /usr/bin/pydoc

Creates a link called /usr/bin/pydoc that points to:

/System/Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc

On my system, this file doesn't exist. Instead, I have:

/System/Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc2.7

Notice the 2.7 at the end.

So you've created a link to a file that doesn't exist and you get a complaint on your command line. The fix is simple, delete /usr/bin/pydoc (first make sure it is a link by typing ls -l /usr/bin and look for pydoc -- if it has an l next to its permissions, then it's a link). Then, type:

sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc2.7 /usr/bin/pydoc

This will create a link to the correct file and you should be able to run pydoc as a script now.

huu
  • 7,032
  • 2
  • 34
  • 49
  • this is interesting. within `/usr/bin` is the link named `pydoc`. i removed it and made a link to pydoc2.7, but I'm still getting the error: `/System/Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc: /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7: bad interpreter: No such file or directory`, and within the directory, `/Library/Frameworks/Python.framework/Versions/2.7/bin` there are `-rwxrwxr-x 1 root wheel 123 Nov 10 2013 pydoc2.7 lrwxr-xr-x 1 root wheel 6 May 1 11:39 pydoc -> pydoc2 lrwxr-xr-x 1 root wheel 8 May 1 11:39 pydoc2 -> pydoc2.7` – MikeiLL May 17 '14 at 04:27
  • wait.. that's odd. so removed the other `pydoc` links in `2.7 bin` so `pydoc2.7' is all that's left. after i create the link to `/System/Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc2.7` using the above command, it seems like the link doesn't contain `/System` in the string. – MikeiLL May 18 '14 at 14:58
  • okay never mind that train of thought. apparently unix starts the link string description from within the `System` folder. now getting error: `/usr/bin/pydoc: /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7: bad interpreter: No such file or directory`, when the pydoc link looks like this: `/System/Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc2.7` and when i cd to `/System/Library/Frameworks/Python.framework/Versions/2.7/bin/`, there's `-rwxrwxr-x 1 root wheel date pydoc2.7`. – MikeiLL May 18 '14 at 15:14