如何在Mac上为Python 3安装鼻子

Fre*_*ell 6 macos nose python-3.x osx-mavericks

我使用easy_install在我的Mac(OS Mavericks)上安装鼻子.它与默认的python 2.7安装工作正常.

如果我使用python 3在模块上运行nosetests,则无法找到导入.我需要知道和做什么,为python 3使用nose?

Mat*_*DMo 8

处理第三方软件包的安装(和删除)的最佳方法是使用pip.首先,下载get-pip.py并保存到某个地方.导航到终端中的该文件夹并输入

sudo python3 get-pip.py
Run Code Online (Sandbox Code Playgroud)

为Python 3安装它.我建议运行

sudo python get-pip.py
Run Code Online (Sandbox Code Playgroud)

以及为Python 2安装它,easy_install不推荐使用.

一旦你已经pip安装了,你应该有机会获得pip3pip-3.3-检查安装目录,看看到底安装了哪些脚本.假设你有命令pip3,你现在可以运行了

sudo pip3 install nose
Run Code Online (Sandbox Code Playgroud)

它将nose在Python 3 site-packages文件夹中安装和依赖,以及nosetestsPython安装bin文件夹中的可执行文件.


Fre*_*ell 4

这些是我发现有效的步骤。感谢 MattDMo 提供的部分。

# use python3 to unstall pip3
sudo python3 get-pip.py
which python3
# ls -l on the result of which to find the target of the link
# Using the path to the target (directory), set up links to pip3, pip3.3
ls -l /Library/Frameworks/Python.framework/Versions/3.3/bin/
ln -s /Library/Frameworks/Python.framework/Versions/3.3/bin/pip3 /usr/local/bin/pip3
ln -s /Library/Frameworks/Python.framework/Versions/3.3/bin/pip3.3 /usr/local/bin/pip3.3
# install nose for python3
# and set a link to the installation
sudo pip3 install nose
ln -s /Library/Frameworks/Python.framework/Versions/3.3/bin/nosetests-3.3 /usr/local/bin/nosetests-3.3
Run Code Online (Sandbox Code Playgroud)