OS X install of Sphinx: The 'sphinx-build' and 'sphinx-quickstart' not found
Question:
There have been several ‘unanswered’ postings on this topic pertaining finding ‘sphinx-build’ not being able to be found:
sphinx-build -h command not found in Mac OS
Sphinx was installed upon OSX using both:
python3 -m pip install sphinx
brew install sphinx
In either case, both commands sphinx-build
and sphinx-quickstart
cannot be found.
Even though python3 -m pip freeze
shows installation:
Sphinx==1.3.6
What am I missing?
Thx
Answers:
I had a similar issue after installing sphinx on OS X El Capitan. I installed sphinx using pip: pip install sphinx --user
. Despite the sphinx-build
binary existing in ~/Library/Python/2.7/bin
, the command could not be found.
The issue was that I had path set to PATH="~/Library/Python/2.7/bin:$PATH"
. Replacing the tilde ~
with $HOME
so that it was PATH="$HOME/Library/Python/2.7/bin:$PATH"
fixed the problem for me.
Following the suggestion of @Dan Murphy
My installation of python 3.4 was at root. Modified ~/.bash_profile
as follows:
export PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin/:$PATH"
If you used homebrew to install Python the paths are slightly different. Here is what I hope is a general method for resolving this problem:
-
Run python3 -c 'import sys; print("n".join(sys.path))'
and look for some lines like .../Python.framework/Versions/3.5/lib/...
.
-
There will be a bin/
that is a sibling of lib/
. That bin/
contains sphinx-quickstart
and the other sphinx commands.
-
For homebrew installed python3 on osx the directory should be /usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/bin
-
Put export PATH=$PATH:.../Python.framework/Versions/3.5/bin
in your bash profile and restart your terminal.
For homebrew, the tools seem to be in sphinx-doc
nowadays. And it’s not by default put in your PATH
either because sphinx-doc
is “keg-only”. To install it and get it into PATH
, you can do:
brew install sphinx-doc
brew link sphinx-doc --force
For full disclosure to the reader, I will include the keg-only warning brew emits when --force
is not used:
Warning: sphinx-doc is keg-only and must be linked with --force
Note that doing so can interfere with building software.
I don’t know why sphinx-doc
is keg-only, but putting sphinx-{quickstart,apidoc,autogen,build}
in PATH
seems harmless to me.
For new users, installing with brew gives the following caveats:
==> sphinx-doc
sphinx-doc is keg-only, which means it was not symlinked into /usr/local,
because this formula is mainly used internally by other formulae.
Users are advised to use `pip` to install sphinx-doc.
If you need to have sphinx-doc first in your PATH, run:
echo 'export PATH="/usr/local/opt/sphinx-doc/bin:$PATH"' >> ~/.zshrc
Running the echo command:
echo 'export PATH="/usr/local/opt/sphinx-doc/bin:$PATH"' >> ~/.zshrc
should fix the issue.
Don’t miss source
-ing the .zshrc after the updating it:
source ~/.zshrc
There have been several ‘unanswered’ postings on this topic pertaining finding ‘sphinx-build’ not being able to be found:
sphinx-build -h command not found in Mac OS
Sphinx was installed upon OSX using both:
python3 -m pip install sphinx
brew install sphinx
In either case, both commands sphinx-build
and sphinx-quickstart
cannot be found.
Even though python3 -m pip freeze
shows installation:
Sphinx==1.3.6
What am I missing?
Thx
I had a similar issue after installing sphinx on OS X El Capitan. I installed sphinx using pip: pip install sphinx --user
. Despite the sphinx-build
binary existing in ~/Library/Python/2.7/bin
, the command could not be found.
The issue was that I had path set to PATH="~/Library/Python/2.7/bin:$PATH"
. Replacing the tilde ~
with $HOME
so that it was PATH="$HOME/Library/Python/2.7/bin:$PATH"
fixed the problem for me.
Following the suggestion of @Dan Murphy
My installation of python 3.4 was at root. Modified ~/.bash_profile
as follows:
export PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin/:$PATH"
If you used homebrew to install Python the paths are slightly different. Here is what I hope is a general method for resolving this problem:
-
Run
python3 -c 'import sys; print("n".join(sys.path))'
and look for some lines like.../Python.framework/Versions/3.5/lib/...
. -
There will be a
bin/
that is a sibling oflib/
. Thatbin/
containssphinx-quickstart
and the other sphinx commands. -
For homebrew installed python3 on osx the directory should be
/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/bin
-
Put
export PATH=$PATH:.../Python.framework/Versions/3.5/bin
in your bash profile and restart your terminal.
For homebrew, the tools seem to be in sphinx-doc
nowadays. And it’s not by default put in your PATH
either because sphinx-doc
is “keg-only”. To install it and get it into PATH
, you can do:
brew install sphinx-doc
brew link sphinx-doc --force
For full disclosure to the reader, I will include the keg-only warning brew emits when --force
is not used:
Warning: sphinx-doc is keg-only and must be linked with --force
Note that doing so can interfere with building software.
I don’t know why sphinx-doc
is keg-only, but putting sphinx-{quickstart,apidoc,autogen,build}
in PATH
seems harmless to me.
For new users, installing with brew gives the following caveats:
==> sphinx-doc
sphinx-doc is keg-only, which means it was not symlinked into /usr/local,
because this formula is mainly used internally by other formulae.
Users are advised to use `pip` to install sphinx-doc.
If you need to have sphinx-doc first in your PATH, run:
echo 'export PATH="/usr/local/opt/sphinx-doc/bin:$PATH"' >> ~/.zshrc
Running the echo command:
echo 'export PATH="/usr/local/opt/sphinx-doc/bin:$PATH"' >> ~/.zshrc
should fix the issue.
Don’t miss source
-ing the .zshrc after the updating it:
source ~/.zshrc