Python 如何在 mac 中安装 setuptools
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26032836/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to install setuptools in mac
提问by Sascuash
I'm trying to install via pipsome libraries but I'm having some problems.
我正在尝试通过pip一些库进行安装,但遇到了一些问题。
When I try to install some of them I require for my project I get this message:
当我尝试为我的项目安装其中一些时,我收到以下消息:
$ sudo pip install dj-database-url==0.2.0
Downloading/unpacking dj-database-url==0.2.0
Downloading dj-database-url-0.2.0.tar.gz
Cleaning up...
setuptools must be installed to install from a source distribution
It also happens when trying to install distribute==0.6.24
尝试安装时也会发生 distribute==0.6.24
Any ideas?
有任何想法吗?
采纳答案by Lingchao Cao
- Download
ez_setup.pymodule from https://pypi.python.org/pypi/setuptools - Open a Terminal.
cdto the directory where you put theez_setup.py.- Type
python ez_setup.pyand run it. - You should have it then.
ez_setup.py从https://pypi.python.org/pypi/setuptools下载模块- 打开一个终端。
cd到您放置ez_setup.py.- 键入
python ez_setup.py并运行它。 - 那时你应该拥有它。
回答by El Diego Efe
After a pip installcommand I was getting the same error as you ("setuptools must be installed to install from a source distribution"). Since I couldn't find a solution, it was a lot faster to reinstall the virtual environment where python was running from.
在执行pip install命令后,我遇到了与您相同的错误(“必须安装 setuptools 才能从源代码分发版安装”)。由于找不到解决方案,重新安装运行python的虚拟环境要快得多。
If you're using virtualenvwrapper this is very easy. First you remove your problematic virtual environment (let's say it is called "venv") with:
如果您使用的是 virtualenvwrapper,这很容易。首先,您使用以下命令删除有问题的虚拟环境(假设它称为“venv”):
rmvirtualenv venv
Then you setup a new one with the same name:
然后你设置一个同名的新的:
mkvirtualenv venv
And finally you install all your packages, including the one you had problems with:
最后,您安装所有软件包,包括您遇到问题的软件包:
pip install dj-database-url

