ReText

ReText is a simple editor that reads your text with MarkDown or HTML markup and saves it as plain text, HTML or PDF.

It is written in Python using Qt libraries.

It's a cross platform program.

Mac OS X Yosemite 上安装

使用 brew 安装:http://sourceforge.net/p/retext/wiki/Home/

以下是部分安装日志:

$ brew tap homebrew/python
==> Tapping Homebrew/python
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-python'...
remote: Counting objects: 16, done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 16 (delta 1), reused 7 (delta 0), pack-reused 0
Unpacking objects: 100% (16/16), done.
Checking connectivity... done.
Tapped 13 formulae (51 files, 216K)

$ brew install retext
==> Installing retext from homebrew/homebrew-python
==> Installing dependencies for retext: xz, pkg-config, readline, sqlite,
==> Installing retext dependency: xz
==> Downloading https://homebrew.bintray.com/bottles/xz-5.2.1.yosemite.bottle.ta
######################################################################## 100.0%
...

安装编译完成后,直接调用 retext 命令即可打开带图形界面的编辑器。That's all,就这么简单。

Mac OS X(10.9.2) 上安装

使用 brew 安装:http://sourceforge.net/p/retext/wiki/Home/

brew tap samueljohn/python
brew install enchant
pip install pyenchant
pip install markups
pip install markdown
pip install docutils

$ brew install retext
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
==> Installing dependencies for retext: qt, sip, pyqt
==> Installing retext dependency: qt
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/qt-4.8.5.mavericks.bottle.4.tar.gz

安装时遇到的问题:

Q1: Could not link glib

$ brew link glib
Linking /usr/local/Cellar/glib/2.38.2... Warning: Could not link glib. Unlinking...

Error: Could not symlink file: /usr/local/Cellar/glib/2.38.2/share/locale/hr/LC_MESSAGES/glib20.mo
/usr/local/share/locale/hr/LC_MESSAGES is not writable. You should change its permissions.

解决方法:

$ sudo chown -R $(whoami):admin /usr/local
$ brew link glib
Linking /usr/local/Cellar/glib/2.38.2... 136 symlinks created

Q2: install enchant error

$ brew install enchant
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
==> Installing enchant dependency: aspell
==> Downloading http://ftpmirror.gnu.org/aspell/aspell-0.60.6.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/aspell-0.60.6.1.tar.gz
==> ./configure --prefix=/usr/local/Cellar/aspell/0.60.6.1
==> make install
20 errors generated.
make[1]: *** [prog/checker_string.o] Error 1
20 errors generated.
make[1]: *** [prog/aspell.o] Error 1
make: *** [install-recursive] Error 1

READ THIS: https://github.com/Homebrew/homebrew/wiki/troubleshooting

解决方法:

$ brew update
$ brew doctor
$ brew install enchant
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
==> Installing dependencies for enchant: glib, aspell
==> Installing enchant dependency: glib
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/glib-2.40.0.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring glib-2.40.0.mavericks.bottle.tar.gz
  /usr/local/Cellar/glib/2.40.0: 410 files, 18M
==> Installing enchant dependency: aspell
==> Downloading http://ftpmirror.gnu.org/aspell/aspell-0.60.6.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/aspell-0.60.6.1.tar.gz
==> Patching
patching file interfaces/cc/aspell.h
==> ./configure --prefix=/usr/local/Cellar/aspell/0.60.6.1
==> make install
==> Downloading http://ftpmirror.gnu.org/aspell/dict/en/aspell6-en-7.1-0.tar.bz2
######################################################################## 100.0%
==> ./configure --vars ASPELL=/usr/local/Cellar/aspell/0.60.6.1/bin/aspell PREZIP=/usr/local/Cellar/aspell/0.60.6.1/bin/prezip
==> make install
  /usr/local/Cellar/aspell/0.60.6.1: 181 files, 6.5M, built in 26 seconds
==> Installing enchant
==> Downloading http://www.abisource.com/downloads/enchant/1.6.0/enchant-1.6.0.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/enchant/1.6.0 --disable-ispell --disable-myspell
==> make install
==> Downloading https://pypi.python.org/packages/source/p/pyenchant/pyenchant-1.6.5.tar.gz
######################################################################## 100.0%
==> python setup.py install --prefix=/usr/local/Cellar/enchant/1.6.0 --single-version-externally-managed --record=installed.txt
==> Caveats
If you need Python to find the installed site-packages:
  mkdir -p ~/Library/Python/2.7/lib/python/site-packages
  echo '/usr/local/lib/python2.7/site-packages' > ~/Library/Python/2.7/lib/python/site-packages/homebrew.pth
==> Summary
  /usr/local/Cellar/enchant/1.6.0: 55 files, 676K, built in 28 seconds

Q3: pip install pyenchant failed.

$ pip install pyenchant
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
    working_set.require(__requires__)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
    raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: pip==1.4.1
donlydeMacBook-Pro:Vizrt Sun-cam$ pip install markups
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
    working_set.require(__requires__)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
    raise DistributionNotFound(req)  # XXX put more info here
pkg_resources.DistributionNotFound: pip==1.4.1

解决办法:

$ sudo easy_install --upgrade pip
Password:
Searching for pip
Reading http://pypi.python.org/simple/pip/
Best match: pip 1.5.4
Downloading https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb
Processing pip-1.5.4.tar.gz
Running pip-1.5.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-hsbdrM/pip-1.5.4/egg-dist-tmp-c3ITXY
warning: no files found matching 'pip/cacert.pem'
warning: no files found matching '*.html' under directory 'docs'
warning: no previously-included files matching '*.rst' found under directory 'docs/_build'
no previously-included directories found matching 'docs/_build/_sources'
Adding pip 1.5.4 to easy-install.pth file
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin

Installed /Library/Python/2.7/site-packages/pip-1.5.4-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip

$ sudo pip install pyenchant

Q4: Install retext

$ brew install retext
Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
==> Downloading https://downloads.sourceforge.net/project/retext/ReText-4.0/ReText-4.0.0.tar.gz
Already downloaded: /Library/Caches/Homebrew/retext-4.0.0.tar.gz
==> python setup.py install --prefix=/usr/local/Cellar/retext/4.0.0
Warning: Formula#python is deprecated and will go away shortly.
Error: undefined method `xy' for #<PythonDependency: "python" []>
Please report this bug:
    https://github.com/Homebrew/homebrew/wiki/troubleshooting
/usr/local/Library/Taps/samueljohn-python/retext.rb:26:in `install'
/usr/local/Library/Homebrew/build.rb:174:in `install'
/usr/local/Library/Homebrew/formula.rb:267:in `brew'
/usr/local/Library/Homebrew/formula.rb:592:in `stage'
/usr/local/Library/Homebrew/resource.rb:62:in `unpack'
/usr/local/Library/Homebrew/extend/fileutils.rb:21:in `mktemp'
/usr/local/Library/Homebrew/resource.rb:59:in `unpack'
/usr/local/Library/Homebrew/resource.rb:52:in `stage'
/usr/local/Library/Homebrew/formula.rb:590:in `stage'
/usr/local/Library/Homebrew/formula.rb:262:in `brew'
/usr/local/Library/Homebrew/build.rb:151:in `install'
/usr/local/Library/Homebrew/build.rb:45:in `main'
/usr/local/Library/Homebrew/build.rb:12
/usr/local/Library/Taps/samueljohn-python/retext.rb:33

解决方法:

直接下载ReText源码,使用brew安装Python3,重新安装PyQt4 --with-python3,进入ReText-4.1.2,输入:

$ python3 setup.py install

running install
running build
running build_py
running build_scripts
copying and adjusting retext.py -> build/scripts-3.4
running install_lib
copying build/lib/.DS_Store -> /usr/local/lib/python3.4/site-packages
running install_scripts
copying build/scripts-3.4/retext.py -> /usr/local/bin
copying build/scripts-3.4/wpgen.py -> /usr/local/bin
changing mode of /usr/local/bin/retext.py to 755
changing mode of /usr/local/bin/wpgen.py to 755
renaming /usr/local/bin/retext.py to /usr/local/bin/retext
renaming /usr/local/bin/wpgen.py to /usr/local/bin/wpgen
running install_data
running install_egg_info
Removing /usr/local/lib/python3.4/site-packages/ReText-4.1.2-py3.4.egg-info
Writing /usr/local/lib/python3.4/site-packages/ReText-4.1.2-py3.4.egg-info

下载资源文件:https://downloads.sourceforge.net/project/retext/Icons/ReTextIcons_r3.tar.gz' 复制到 /usr/local/lib/python3.4/site-packages/ReText/icons,修改 /usr/local/lib/python3.4/site-packages/ReText/__init__.py 中的 icon_path = "/usr/local/lib/python3.4/site-packages/ReText/icons/"

最终运行效果图:

ReText 4.1.2

参考资料

Wiki

更新日志

  • 2015-05-17:增加 Mac OS X Yosemite 上安装