Virtualenv: Need pydoc in $VIRTUALENV/bin

Created on 6 Jul 2011  路  18Comments  路  Source: pypa/virtualenv

The bin directory should include a pydoc executable:

#!/usr/bin/env python

import pydoc
if __name__ == '__main__':
     pydoc.cli()

Most helpful comment

I've mentioned it before already, but an alias/shell function is different from an executable.

As of now pyenv-virtualenv creates a pydoc executable itself, and in general some custom shell wrapper that calls python -m pydoc should do:

#!/bin/sh

python -m pydoc "$@"

All 18 comments

Hm, that's actually an intriguing idea, due to the hard coded shebangs in the pydoc (and other scripts installed by Python), we probably have to copy those files around, indeed.

What other binaries are installed with every Python installation?

From a brew install --framework version....

$ ls -1 /usr/local/Cellar/python/2.7.2/bin/
2to3
2to3-2.7
idle
idle2.7
pydoc
pydoc2.7
python
python-config
python2.7
python2.7-config
pythonw
pythonw2.7
smtpd.py
smtpd2.7.py

These ones are just shebang fixes:

2to3-2.7
idle
idle2.7
pydoc
pydoc2.7
python-config
python2.7-config
smtpd.py
smtpd2.7.py

Ugh, this just bit me.... I was getting wrong FILE in pydoc output, so I did which pydoc and that of course points to system version.

Now I checked commit/pull source and I see it's alias'ed, which means that pydoc redirection is not propagated to child processes, e.g.:

bash1$ ./xxx/activate
bash1$ pydoc special # ok
bash1$ bash
bash2$ python # ok
bash2# pydoc special # oops!

I vote for proper pydoc, 2to3, etc scripts in virtualenv bin.

Is there an update on this? The alias doesn't work for me at all... I'd much prefer those scripts being in venv/bin

Does using something like

./ve/bin/python -m pydoc -k special

Work? If you are starting a new shell then I wouldn't expect the activate stuff to work. activate is a convenience you can just use the virtualenv interpreter directly

yes, "python -m pydoc ..." works.

@jantman I suspect at this stage, it's on you to submit a patch...

Ideally virtualenv should install into [env]/bin/ everything that python installs in /usr/bin/ :

python
pydoc
idle # if exists
python-config
2to3

Yes that ... "hack" IMO... works. What's confusing to me is that I can't

source bin/activate
pydoc foo.py

and have it work as expected.

@dimaqq Fair enough about the patch. I doubt I'll get around to it soon, but I'll append it to my list...

Thanks for letting me know that this works with a virtualenv (typed below for others):

python -m pydoc myproject

but it would be really nice if virtualenv install its own pydoc.

@ianb
Can we please reopen this and have a proper binary for pydoc?

While python -m pydoc works (where an alias does not), there are tools/plugins around that just check for pydoc.
My example is using pyenv which provides "shims" for the regular python binaries and proxies it to the activated version. But when using a virtualenv it results in an error that this command is only available in other (normal) python versions.

Now the workaround is to configure the Vim plugin in question to use python -m pydoc, but that could be avoided.

Should I open a new issue for the comment above?

pydoc is now included in virtualenv scripts as a shell function for unix activate scripts

How about Windows activate scripts?

alias? On Windows?

doskey pydoc=python -m pydoc

I've mentioned it before already, but an alias/shell function is different from an executable.

As of now pyenv-virtualenv creates a pydoc executable itself, and in general some custom shell wrapper that calls python -m pydoc should do:

#!/bin/sh

python -m pydoc "$@"
Was this page helpful?
0 / 5 - 0 ratings

Related issues

mitchhentges picture mitchhentges  路  3Comments

asottile picture asottile  路  6Comments

earthgecko picture earthgecko  路  4Comments

Tset-Noitamotua picture Tset-Noitamotua  路  4Comments

schlamar picture schlamar  路  4Comments