Python 3.3 和在 Mac 上安装 PyOpenSSL [英] Python 3.3 and Installing PyOpenSSL on a Mac

查看:28
本文介绍了Python 3.3 和在 Mac 上安装 PyOpenSSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 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目录

除了我假设安装程序会创建的目录不存在之外,更大的问题是它似乎正在尝试写入 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):

  1. 安装pip
  1. 使用适用于您的操作系统的软件包安装它.例如,如果您使用 brew,请brew install pip.
  2. 如果您的操作系统没有软件包,请下载https://raw.github.com/pypa/pip/master/contrib/get-pip.py
  3. 运行它(很可能是 root,不幸的是):sudo python get-pip.py

  • 使用pip安装virtualenv - pip install --user virtualenv
  • 创建一个 virtualenv 以将 pyOpenSSL 安装到 - virtualenv ~/Environments/pyOpenSSL-stuff
  • 激活 virtualenv - .~/Environments/pyOpenSSL-stuff/bin/activate
  • 使用 pip 安装 pyOpenSSL - 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屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆