Python 3.3和在Mac上安装PyOpenSSL [英] Python 3.3 and Installing PyOpenSSL on a Mac
问题描述
我有python 3.3,可以运行一些基本代码(例如print("Hello World")
).接下来,我需要设置PyOpenSSL.我已经从他们的github网站下载了pyOpenSSL-master.zip
并解压缩了,但是我不知道下一步该怎么做.
I have python 3.3 working and can run some basic code (like print("Hello World")
). Next I need so get PyOpenSSL set up. I've downloaded and unzipped the pyOpenSSL-master.zip
from their github site, but I have no idea what to do with it next.
我将解压缩的目录移到了/libs
,将cd移到了/libs/pyopenssl-master
,然后执行了python setup.py install --user
.但这失败了
I moved the unzipped directory into /libs
, cd into /libs/pyopenssl-master
and did python setup.py install --user
. But that failed with
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'setup.py': [Errno 2] No such file or directory
除了目录不存在(我认为安装程序会创建该目录)之外,更大的问题是它似乎正在尝试写入python 2.7文件夹,而我正在使用3.3.
Other than the directory not existing, which I assume that the installer would create, the bigger problem is that it appears to be trying to write to the python 2.7 folder and I'm using 3.3.
如果您不能告诉我,我的能力已经远远超出了我的水平.我以前从未安装过Python库,并且对OSX的安装也不满意.任何人都可以帮助我进行此设置吗?谢谢.
If you can't tell, I'm pretty much out of my element. I've never installed a Python library before and I'm also not great with OSX installations. Can anyone help me get this set up? Thanks.
推荐答案
以下是在OS X(或几乎任何其他平台)上安装pyOpenSSL的方法:
Here's how you can install pyOpenSSL on OS X (or just about any other platform):
- 安装点子
- 使用适用于您的操作系统的软件包进行安装.例如,如果您使用brew,则
brew install pip
. - 如果没有适用于您操作系统的软件包,请下载 https ://raw.github.com/pypa/pip/master/contrib/get-pip.py
- 运行它(不幸的是,可能是root用户):
sudo python get-pip.py
- Install it using a package for your operating system. For example, if you use brew,
brew install pip
. - If there is no package for your operating system, download https://raw.github.com/pypa/pip/master/contrib/get-pip.py
- Run it (probably as root, unfortunately):
sudo python get-pip.py
pip install --user virtualenv
virtualenv ~/Environments/pyOpenSSL-stuff
. ~/Environments/pyOpenSSL-stuff/bin/activate
pip install pyopenssl
pip install --user virtualenv
virtualenv ~/Environments/pyOpenSSL-stuff
. ~/Environments/pyOpenSSL-stuff/bin/activate
pip install pyopenssl
这时,您已经在virtualenv中安装了pyOpenSSL.每当您要使用pyOpenSSL时,都需要激活virtualenv.我建议您实际上为您从事的您的每个项目创建一个virtualenv,并将每个项目的所有必要依赖项安装到该项目的virtualenv中.
At this point you have pyOpenSSL installed in a virtualenv. Any time you want to use pyOpenSSL you'll need to activate the virtualenv. I suggest that you actually create a virtualenv for each project of yours that you work on and install all of the necessary dependencies for each project into that project's virtualenv.
这确实导致大量重复安装软件包.不幸的是,这似乎是Python软件包安装的最新技术.幸运的是,大多数Python软件包都很小.
This does result in a lot of duplicate installations of packages. Unfortunately this seems to be the state of the art for Python package installation. Fortunately most Python packages are rather small.
这篇关于Python 3.3和在Mac上安装PyOpenSSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!