嗨,我在Mac OS Mavericks上,我玩了一下python安装,以获得python命令来显示新更新的python 3.4.1。但事情似乎有些混乱。当我输入 终端上的python3 -v,这就是我得到的。
import _frozen_importlib # frozen
import imp # builtin
import sys # builtin
# installing zipimport hook
# installed zipimport hook
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/encodings/__pycache__/__init__.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/encodings/__init__.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/encodings/__pycache__/__init__.cpython-34.pyc'
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/codecs.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/codecs.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/codecs.cpython-34.pyc'
import 'codecs' # <_frozen_importlib.SourceFileLoader object at 0x1003e2160>
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/encodings/__pycache__/aliases.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/encodings/aliases.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/encodings/__pycache__/aliases.cpython-34.pyc'
import 'encodings.aliases' # <_frozen_importlib.SourceFileLoader object at 0x1003f2da0>
import 'encodings' # <_frozen_importlib.SourceFileLoader object at 0x1003ddcf8>
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/encodings/__pycache__/utf_8.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/encodings/utf_8.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/encodings/__pycache__/utf_8.cpython-34.pyc'
import 'encodings.utf_8' # <_frozen_importlib.SourceFileLoader object at 0x10062aa90>
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/encodings/__pycache__/latin_1.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/encodings/latin_1.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/encodings/__pycache__/latin_1.cpython-34.pyc'
import 'encodings.latin_1' # <_frozen_importlib.SourceFileLoader object at 0x100630588>
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/io.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/io.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/io.cpython-34.pyc'
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/abc.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/abc.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/abc.cpython-34.pyc'
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/_weakrefset.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/_weakrefset.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/_weakrefset.cpython-34.pyc'
import '_weakrefset' # <_frozen_importlib.SourceFileLoader object at 0x100636278>
import 'abc' # <_frozen_importlib.SourceFileLoader object at 0x100630a20>
import 'io' # <_frozen_importlib.SourceFileLoader object at 0x100630780>
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/site.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/site.cpython-34.pyc'
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/os.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/os.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/os.cpython-34.pyc'
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/stat.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/stat.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/stat.cpython-34.pyc'
import 'stat' # <_frozen_importlib.SourceFileLoader object at 0x100656160>
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/posixpath.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/posixpath.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/posixpath.cpython-34.pyc'
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/genericpath.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/genericpath.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/genericpath.cpython-34.pyc'
import 'genericpath' # <_frozen_importlib.SourceFileLoader object at 0x10065ca20>
import 'posixpath' # <_frozen_importlib.SourceFileLoader object at 0x1006563c8>
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/_collections_abc.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/_collections_abc.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/_collections_abc.cpython-34.pyc'
import '_collections_abc' # <_frozen_importlib.SourceFileLoader object at 0x10065c940>
import 'os' # <_frozen_importlib.SourceFileLoader object at 0x100645f98>
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/_sitebuiltins.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/_sitebuiltins.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/_sitebuiltins.cpython-34.pyc'
import '_sitebuiltins' # <_frozen_importlib.SourceFileLoader object at 0x100655128>
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/sysconfig.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/sysconfig.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/sysconfig.cpython-34.pyc'
import 'sysconfig' # <_frozen_importlib.SourceFileLoader object at 0x1006f1dd8>
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/_sysconfigdata.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/_sysconfigdata.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/_sysconfigdata.cpython-34.pyc'
import '_sysconfigdata' # <_frozen_importlib.SourceFileLoader object at 0x1006fa630>
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/_osx_support.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/_osx_support.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/_osx_support.cpython-34.pyc'
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/re.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/re.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/re.cpython-34.pyc'
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/sre_compile.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/sre_compile.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/sre_compile.cpython-34.pyc'
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/sre_parse.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/sre_parse.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/sre_parse.cpython-34.pyc'
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/sre_constants.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/sre_constants.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/sre_constants.cpython-34.pyc'
import 'sre_constants' # <_frozen_importlib.SourceFileLoader object at 0x100721eb8>
import 'sre_parse' # <_frozen_importlib.SourceFileLoader object at 0x100719588>
import 'sre_compile' # <_frozen_importlib.SourceFileLoader object at 0x100713550>
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/copyreg.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/copyreg.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/copyreg.cpython-34.pyc'
import 'copyreg' # <_frozen_importlib.SourceFileLoader object at 0x1007285c0>
import 're' # <_frozen_importlib.SourceFileLoader object at 0x10070f630>
import '_osx_support' # <_frozen_importlib.SourceFileLoader object at 0x100709780>
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/_bootlocale.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/_bootlocale.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/_bootlocale.cpython-34.pyc'
import '_bootlocale' # <_frozen_importlib.SourceFileLoader object at 0x10070f550>
import 'site' # <_frozen_importlib.SourceFileLoader object at 0x10063bb00>
Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 00:54:21)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
# extension module loaded from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/lib-dynload/readline.so'
# /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/rlcompleter.cpython-34.pyc matches /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/rlcompleter.py
# code object from '/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/__pycache__/rlcompleter.cpython-34.pyc'
import 'rlcompleter' # <_frozen_importlib.SourceFileLoader object at 0x10073a518>
>>>
我的问题是如何从系统中删除所有其他版本的python,并且在系统上只有最新版本的python 3.4.1。此外,我不想使用自制软件或macports进行安装。进一步如何在python安装后安装pip。最后,如何更改system python命令以读取python3。因此,如果我在系统上键入python -v,它应该输出python 3.4.1。
答案 0 :(得分:2)
首先,w.r.t:&#34;我的问题是如何从系统中删除所有其他版本的python,并且在系统上只有最新版本的python 3.4.1&#34;
不要这样做!如果你吹掉苹果版本的Python,那么你的系统将无法使用。
1)从python网站安装python3.x
2)将自定义安装的路径添加到.profile。这是我的.profile:
#PYTHON
export PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin/:$PATH
export PATH=/Library/Frameworks/Python.framework/Versions/3.3/bin/:$PATH
3)重新启动。当您现在键入&#34; python3&#34;时,搜索路径时,它会找到并使用您安装的版本而不是Apple版本。
4)如果你发现打字&#34; python3&#34;要成为一种负担,您可以将alias py3=python3
添加到.profile中,这样可以确保在键入py3
时调用python3。我不推荐使用别名python
,因为如果必须的话你就不能调用python2。
5)以下是pip安装说明:https://pip.pypa.io/en/latest/installing.html#install-or-upgrade-pip