简体   繁体   中英

Python installation error on mac OS Mavericks

Hi I'm on Mac OS Mavericks and I played around with the python installation a bit to get the python command to display the new updated python 3.4.1. But things seem a bit messed up. When I type python3 -v on the terminal, this is what I get.

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>
>>> 

My questions are how can I delete all other versions of python from the system and just have the latest version which is python 3.4.1 on the system. Also I dont want to use homebrew or macports for the installation. Further how can I install pip subsequent to python installation. Finally how do I change the system python command to read python3. Thus if I type python -v on the system it should output python 3.4.1.

First, wrt: "My questions are how can I delete all other versions of python from the system and just have the latest version which is python 3.4.1 on the system"

Do NOT DO THIS! If you blow away the apple versions of Python, your system will be UNUSABLE.

1) Install python3.x from the python website

2) Add the path to the custom installation to your .profile. Here is mine in my .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) Reboot. When you now type "python3", when searching though paths it will find and use your installed version instead of the apple version.

4) If you find typing "python3" to be a burden, you can add alias py3=python3 to your .profile and that will ensure python3 is called if you type py3 . I wouldn't recommend aliasing python because then you couldn't call python2 if you had to.

5) Here are the pip install instructions: https://pip.pypa.io/en/latest/installing.html#install-or-upgrade-pip

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM