【问题标题】:pycrypto massup when install with crypto on mac在 Mac 上安装加密时的 pycrypto massup
【发布时间】:2018-05-31 17:09:31
【问题描述】:

我正在尝试将cryptopycrypto 安装在同一个虚拟环境中。

[root@jnkslave01 tmp]# virtualenv test_pycrypto
New python executable in /root/tmp/test_pycrypto/bin/python
Installing setuptools, pip, wheel...done.
[root@jnkslave01 tmp]# source test_pycrypto/bin/activate
(test_pycrypto) [root@jnkslave01 tmp]# pip install crypto==1.4.1 pycrypto==2.6.1 
Collecting crypto==1.4.1
/root/tmp/test_pycrypto/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/root/tmp/test_pycrypto/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/root/tmp/test_pycrypto/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/root/tmp/test_pycrypto/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading https://pypi.storage.rackspace.com/packages/crypto-1.4.1-py2.py3-none-any.whl
Collecting pycrypto==2.6.1
/root/tmp/test_pycrypto/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/root/tmp/test_pycrypto/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Requirement already satisfied: Naked in ./test_pycrypto/lib/python2.6/site-packages (from crypto==1.4.1)
Requirement already satisfied: shellescape in ./test_pycrypto/lib/python2.6/site-packages (from crypto==1.4.1)
Requirement already satisfied: requests in ./test_pycrypto/lib/python2.6/site-packages (from Naked->crypto==1.4.1)
Requirement already satisfied: pyyaml in ./test_pycrypto/lib/python2.6/site-packages (from Naked->crypto==1.4.1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in ./test_pycrypto/lib/python2.6/site-packages (from requests->Naked->crypto==1.4.1)
Requirement already satisfied: certifi>=2017.4.17 in ./test_pycrypto/lib/python2.6/site-packages (from requests->Naked->crypto==1.4.1)
Requirement already satisfied: urllib3<1.23,>=1.21.1 in ./test_pycrypto/lib/python2.6/site-packages (from requests->Naked->crypto==1.4.1)
Requirement already satisfied: idna<2.7,>=2.5 in ./test_pycrypto/lib/python2.6/site-packages (from requests->Naked->crypto==1.4.1)
Installing collected packages: crypto, pycrypto
Successfully installed crypto-1.4.1 pycrypto-2.6.1
(test_pycrypto) [root@jnkslave01 tmp]# python -c "from Crypto import Random"
(test_pycrypto) [root@jnkslave01 tmp]#
(test_pycrypto) [root@jnkslave01 tmp]# cat /etc/issue
CentOS release 6.9 (Final)
Kernel \r on an \m

它在CentOS 6.9 中工作正常,但是当我尝试在我的 Mac 中这样做时。它给出了错误。

(test_pycrypto) ABCDEFG:~ myuser$ python -c "from Crypto import Random"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named Crypto

当我检查时,这两种设置有什么区别,我在Mac 发现它在crypto 目录中的crypto 中安装Cryptosite-packages

在 Mac 上

(test_pycrypto) ABCDEFG:~ myuser$ ls test_pycrypto/lib/python2.6/site-packages/crypto/
Cipher          PublicKey       Signature       __init__.pyc        decryptoapp.py      pct_warnings.py     settings.pyc
Hash            Random          Util            app.py          decryptoapp.pyc     pct_warnings.pyc
Protocol        SelfTest        __init__.py     app.pyc         library         settings.py
(test_pycrypto) ABCDEFG:~ myuser$ ls test_pycrypto/lib/python2.6/site-packages/Crypto/
Cipher          PublicKey       Signature       __init__.pyc        decryptoapp.py      pct_warnings.py     settings.pyc
Hash            Random          Util            app.py          decryptoapp.pyc     pct_warnings.pyc
Protocol        SelfTest        __init__.py     app.pyc         library         settings.py

在 Mac 上,它以某种方式组合两个包并将相同的内容放在两个目录中,而在 CentOS 上,它的两个目录都有不同的内容。

在 CentOS 上

(test_pycrypto) [root@jnkslave01 tmp]# ls test_pycrypto/lib/python2.6/site-packages/crypto
app.py  app.pyc  decryptoapp.py  decryptoapp.pyc  __init__.py  __init__.pyc  library  settings.py  settings.pyc
(test_pycrypto) [root@jnkslave01 tmp]# ls test_pycrypto/lib/python2.6/site-packages/Crypto/
Cipher  Hash  __init__.py  __init__.pyc  pct_warnings.py  pct_warnings.pyc  Protocol  PublicKey  Random  SelfTest  Signature  Util

我在两个设置中运行了相同的命令,也尝试了Python 3,它有同样的问题。

我在 Mac 上做错了什么,导致了这个问题?

【问题讨论】:

    标签: python macos centos pip pycrypto


    【解决方案1】:

    Mac OS X 的文件系统不区分大小写,不区分Cryptocrypto。您不能将两者都安装到同一个虚拟环境中。将它们分开。

    【讨论】:

    • 还有一个问题,如果mac不能区分,那么当我做from Crypto import Random时它应该在test_pycrypto/lib/python2.6/site-packages/crypto/中找到,因为这个目录里面有Random包。
    • 创建或挂载区分大小写的文件系统。使用命令 newfs_hfs -s 创建一个新的区分大小写的 HFS(不要在实时系统上进行试验并始终进行备份!)或者从外部驱动器或通过网络安装区分大小写的文件系统。
    • 我不知道 Python 在不区分大小写的文件系统上的表现如何。可能是 Python 将 cryptoCrypto 区分开来,如果已安装 crypto,则无法找到 Crypto
    • 用文件系统做实验相当困难,也许你可以操纵其中一个模块——例如,安装crypto,重命名它的目录并重写代码——修复import cryptofrom crypto import…。之后安装Crypto
    猜你喜欢
    • 1970-01-01
    • 2016-02-26
    • 1970-01-01
    • 2015-07-10
    • 1970-01-01
    • 1970-01-01
    • 2020-11-18
    • 2011-08-22
    • 1970-01-01
    相关资源
    最近更新 更多