【发布时间】:2018-10-16 08:30:20
【问题描述】:
在 Mac OS X 上,我安装了几个 Python 版本,用于 afdk(字体修改模块)。有人建议我删除它们并重新开始,我已经这样做了。
查看 .profile、.bash.profile、.profile.pysave 文件,我发现我安装的所有以前的版本都被记录下来。为了只使用最新的 Python 版本,我应该通过删除旧版本来破解这些 .bash 文件,并且只保留当前 Python 版本的 $PATH 吗?
$ echo $PATH
/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/adrianshome/bin/FDK/Tools/osx
谢谢, 阿德里安
下面是提到的 .bash 文件。
.profile:
##
# DELUXE-USR-LOCAL-BIN-INSERT
# (do not remove this comment)
##
echo $PATH | grep -q -s "/usr/local/bin"
if [ $? -eq 1 ] ; then
PATH=$PATH:/usr/local/bin
export PATH
fi
# Setting PATH for MacPython 2.5
# The orginal version is saved in .profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
# Setting PATH for Python 3.4
# The orginal version is saved in .profile.pysave
# Initialization for FDK command line tools.Sun Oct 14 12:28:07 2018
FDK_EXE="/Users/adrianshome/bin/FDK/Tools/osx"
PATH=${PATH}:"/Users/adrianshome/bin/FDK/Tools/osx"
export PATH
export FDK_EXE
.profile.pysave:
##
# DELUXE-USR-LOCAL-BIN-INSERT
# (do not remove this comment)
##
echo $PATH | grep -q -s "/usr/local/bin"
if [ $? -eq 1 ] ; then
PATH=$PATH:/usr/local/bin
export PATH
fi
# Setting PATH for MacPython 2.5
# The orginal version is saved in .profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
export PATH
# Initialization for FDK command line tools.Wed May 21 12:21:59 2008
FDK_EXE="/Users/adrianwi/bin/FDK/Tools/osx"
PATH=${PATH}:"/Users/adrianwi/bin/FDK/Tools/osx"
.bash.profile:
# Initialization for FDK command line tools.Fri Apr 10 14:12:30 2015
# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
# Setting PATH for Python 2.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
# Setting PATH for Python 2.7
这是安装 Python3 和 AFDK 模块的结果...
Last login: Sun Oct 14 12:50:11 on ttys001
Adrians-iMac-2:~ adrianshome$ pip3 install --user --upgrade afdko;
Collecting afdko
Downloading https://files.pythonhosted.org/packages/b6/d2/0ba8ccfe42b0f88b0cc2819b73d93d4ad6240285a8d9a6a1570f39b1e613/afdko-2.8.2-py2.py3-none-macosx_10_6_intel.whl (2.4MB)
100% |████████████████████████████████| 2.4MB 543kB/s
Collecting ufoLib~=2.3.1 (from afdko)
Downloading https://files.pythonhosted.org/packages/b7/72/e053c7f9adc52ee7f4ac163cebef4c8d39732a79a02f9abcfdcfbca35785/ufoLib-2.3.2-py2.py3-none-any.whl (109kB)
100% |████████████████████████████████| 112kB 525kB/s
Collecting ufonormalizer~=0.3.5 (from afdko)
Downloading https://files.pythonhosted.org/packages/e6/f3/cdf8d7616cde052b07f3fb83eec34a4a534965df71968cbef9f3895a31c3/ufonormalizer-0.3.5-py2.py3-none-any.whl
Collecting defcon~=0.5.3 (from afdko)
Downloading https://files.pythonhosted.org/packages/e5/e5/7491cd6b2f5ec7ef96804f31b8c5fd4d8030d2ff7f331fc2c179ff196bfa/defcon-0.5.3-py2.py3-none-any.whl (212kB)
100% |████████████████████████████████| 215kB 1.6MB/s
Collecting booleanOperations~=0.8.0 (from afdko)
Downloading https://files.pythonhosted.org/packages/bd/98/4c43398f43b023803609ac4ab46b02f10936ba501c8e53e70ee8f21d794d/booleanOperations-0.8.0-py2.py3-none-any.whl
Collecting fontTools~=3.29.1 (from afdko)
Downloading https://files.pythonhosted.org/packages/ab/68/a583423ac2ca5dd624ca4914ee97307b4b61a83dda5e0451f0242f628f58/fonttools-3.29.1-py2.py3-none-any.whl (612kB)
100% |████████████████████████████████| 614kB 551kB/s
Collecting psautohint==1.8.1 (from afdko)
Downloading https://files.pythonhosted.org/packages/50/95/4583fcdb5cca5efe32c46dfa2bab95fcf2a99f43a8fd201971b5978d4705/psautohint-1.8.1-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (377kB)
100% |████████████████████████████████| 378kB 486kB/s
Collecting mutatorMath~=2.1.1 (from afdko)
Downloading https://files.pythonhosted.org/packages/01/26/6d1583731da1d236f917b6618ac342ad435eb761750f934f1fc1bfd9ae84/MutatorMath-2.1.1-py2.py3-none-any.whl
Collecting fontMath~=0.4.7 (from afdko)
Downloading https://files.pythonhosted.org/packages/33/b2/6e4d8fd1c0c82f42961dd4e901ecf819e490a64f2abb0a7bdf5082997a4f/fontMath-0.4.7-py2.py3-none-any.whl
Collecting fontPens~=0.1.0 (from afdko)
Downloading https://files.pythonhosted.org/packages/76/11/0ad531d40c608eb3b798bb94607b10109b4e145142fe68eda40e92b84daf/fontPens-0.1.0-py2.py3-none-any.whl
Collecting pyclipper>=1.0.5 (from booleanOperations~=0.8.0->afdko)
Downloading https://files.pythonhosted.org/packages/a0/2f/6a75e90bfb924118bd65cc16ccd23df53db697f0df7a4dfa79c6d64913fe/pyclipper-1.1.0.post1-cp37-cp37m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (275kB)
100% |████████████████████████████████| 276kB 510kB/s
Installing collected packages: fontTools, ufoLib, ufonormalizer, defcon, pyclipper, booleanOperations, psautohint, fontMath, mutatorMath, fontPens, afdko
The scripts fonttools, pyftinspect, pyftmerge, pyftsubset and ttx are installed in '/Users/adrianshome/Library/Python/3.7/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
The script ufonormalizer is installed in '/Users/adrianshome/Library/Python/3.7/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
The script psautohint is installed in '/Users/adrianshome/Library/Python/3.7/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
The scripts autohint, buildcff2vf, buildmasterotfs, charplot, checkoutlinesufo, comparefamily, digiplot, fontplot, fontplot2, fontsetplot, hintplot, makeinstancesufo, makeotf, otc2otf, otf2otc, stemhist, ttfcomponentizer, ttxn and waterfallplot are installed in '/Users/adrianshome/Library/Python/3.7/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed afdko-2.8.2 booleanOperations-0.8.0 defcon-0.5.3 fontMath-0.4.7 fontPens-0.1.0 fontTools-3.29.1 mutatorMath-2.1.1 psautohint-1.8.1 pyclipper-1.1.0.post1 ufoLib-2.3.2 ufonormalizer-0.3.5
Adrians-iMac-2:~ adrianshome$ echo $PATH
/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/adrianshome/bin/FDK/Tools/osx
Adrians-iMac-2:~ adrianshome$
Adrians-iMac-2:~ adrianshome$
更新:11 月 2 日
感谢非常好的解释!我重新安装了 Python3 并执行了“pip3 install --user --upgrade afdko”来获得我需要的字体工具模块。创建了一个虚拟环境。然后再次运行我的代码例程,出现关于“站点包”目录中未找到的模块的错误 - 即使它们在那里:
将 ttx 拖到终端
粘贴代码以在桌面上创建“Dsig fldr”,其中包含 dsig.ttx 文件。
输入'-m'
将“SassoInfProReg.ttf”拖到终端
将“dsig.ttx”拖到终端
返回
有了这个结果(为代码不是全等宽的道歉?)...
(env37) Adrians-iMac-2:Dsig fldr adrianshome$ FLDR="${HOME}/Desktop/Dsig fldr"
(env37) Adrians-iMac-2:Dsig fldr adrianshome$ mkdir -p "$FLDR" (env37) Adrians-iMac-2:Dsig fldr adrianshome$ cd "$FLDR" (env37) Adrians-iMac-2:Dsig fldr adrianshome$ cat > dsig.ttx
00000001 00000000 EOF (env37) Adrians-iMac-2:Dsig fldr adrianshome$ open 。 (env37) Adrians-iMac-2:Dsig fldr adrianshome$ /Library/Python/3.7/bin/ttx -m /Users/adrianshome/Desktop/Dsig\ fldr/SassoInfProReg.ttf /Users/adrianshome/Desktop/Dsig\ fldr/ dsig.ttx
正在将“/Users/adrianshome/Desktop/Dsig fldr/dsig.ttx”编译为“/Users/adrianshome/Desktop/Dsig fldr/dsig.ttf”... 正在解析“DSIG”表... 错误:发生未处理的异常 Traceback(最近一次调用最后一次):
文件“/Users/adrianshome/Library/Python/3.7/lib/python/site-packages/fontTools/ttx.py”,第 398 行,在 main 流程(工作,选项)
文件“/Users/adrianshome/Library/Python/3.7/lib/python/site-packages/fontTools/ttx.py”,第 372 行,正在处理中 动作(输入、输出、选项)
文件“/Users/adrianshome/Library/Python/3.7/lib/python/site-packages/fontTools/misc/loggingTools.py”,第 375 行,在包装器中 返回函数(*args, **kwds)
文件“/Users/adrianshome/Library/Python/3.7/lib/python/site-packages/fontTools/ttx.py”,第 290 行,在 ttCompile ttf.save(输出)
文件“/Users/adrianshome/Library/Python/3.7/lib/python/site-packages/fontTools/ttLib/ttFont.py”,第 173 行,保存 writer_reordersTables = self._save(tmp)
文件“/Users/adrianshome/Library/Python/3.7/lib/python/site-packages/fontTools/ttLib/ttFont.py”,第 212 行,在 _save self._writeTable(tag, writer, done, tableCache)
文件“/Users/adrianshome/Library/Python/3.7/lib/python/site-packages/fontTools/ttLib/ttFont.py”,第 633 行,在 _writeTable tabledata = self.getTableData(tag)
文件“/Users/adrianshome/Library/Python/3.7/lib/python/site-packages/fontTools/ttLib/ttFont.py”,第 651 行,在 getTableData return self.tables[tag].compile(self)
文件“/Users/adrianshome/Library/Python/3.7/lib/python/site-packages/fontTools/ttLib/tables/D_S_I_G_.py”,第 60 行,编译 打包 = sstruct.pack(DSIG_HeaderFormat, self)
文件“/Users/adrianshome/Library/Python/3.7/lib/python/site-packages/fontTools/misc/sstruct.py”,第 68 行,包中 值 = 对象 [名称] 键错误:'ulVersion' (env37) Adrians-iMac-2:Dsig fldr adrianshome$
【问题讨论】:
标签: python bash macos dependencies