【发布时间】:2017-11-19 13:08:16
【问题描述】:
我知道有人问过这个问题 - 但似乎没有任何解决方案有效。我最近发现在 Mac OS 上,python 的本机安装不是很好。所以,我安装了自制软件,并通过那里安装了 Python 2。我的路径如下:
~ echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin
但是,我仍然得到以下信息:
~ which python
/usr/bin/python
~ which python2
/usr/local/bin/python2
还需要注意的是,我的 ~/.bash_profile、~/.profile 和 ~/.zshrc 文件是空的。
不知何故,我想我让 pip 可以使用python2(自制)安装。基本上,我做了pip install pandas,我得到了两个python解释器的以下输出:
~ python
Python 2.7.10 (default, Feb 7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pandas
也就是说,它不会出现在默认的 python 安装中。但是,我也有以下几点:
~ python2
Python 2.7.14 (default, Sep 25 2017, 09:53:22)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>>
因此,pandas 是在 python2(自制)python 中导入的,但不是标准的。我怎样才能得到它,以便默认的 python 是我的自制 python?我还在某处读到 brew link python 会起作用,但是当我这样做时,我得到了
~ brew link python
Warning: Already linked: /usr/local/Cellar/python/2.7.14
To relink: brew unlink python && brew link python
我希望能够只使用python my_file.py 并让它使用自制软件安装。 (不确定它是否相关,但希望这也允许 Sublime 在我点击命令 + B 时使用自制软件安装)。
抱歉,我的新电脑太长了,在我做任何大项目之前,我正努力把这一切都纠正过来,然后发现事情并没有按照我需要的方式工作。
谢谢!
【问题讨论】:
-
brew doctor有什么有趣的话要说吗? -
它说的是
Your system is ready to brew.
标签: python macos python-2.7