mac 上的 paramiko 软件包 1.4.1 安装错误
Installation Error on paramiko package 1.4.1 on mac
我最近正在尝试 运行 一段带有 paramiko 的代码,该代码只是构建一个基本的 ssh 端口并且可以在其他 machines 上使用该代码。但是,当我安装 paramiko 和 运行 我自己的代码 machine 时,它不起作用。我仔细检查了代码以确保它是相同的。然后我在编译时检查了错误,它说:
import paramiko
File "/Library/Python/2.7/site-packages/paramiko/__init__.py", line 30, in <module>
from paramiko.transport import SecurityOptions, Transport
File "/Library/Python/2.7/site-packages/paramiko/transport.py", line 33, in <module>
from cryptography.hazmat.backends import default_backend
File "/Library/Python/2.7/site-packages/cryptography/hazmat/backends/__init__.py", line 7, in <module>
import pkg_resources
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 72, in <module>
import packaging.requirements
File "/Library/Python/2.7/site-packages/packaging/requirements.py", line 59, in <module>
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
TypeError: __call__() takes exactly 2 arguments (1 given)
我在网上寻找答案,它说我可能遇到的问题是我没有 crypto 1.4.1 包。因此,我使用 pip 安装包,由于某种原因,我收到了与 运行 安装程序相同的错误。
pip install crypto
Collecting crypto
Using cached crypto-1.4.1-py2.py3-none-any.whl
Collecting shellescape (from crypto)
Using cached shellescape-3.4.1-py2.py3-none-any.whl
Collecting Naked (from crypto)
Using cached Naked-0.1.31-py2.py3-none-any.whl
Collecting requests (from Naked->crypto)
Using cached requests-2.13.0-py2.py3-none-any.whl
Collecting pyyaml (from Naked->crypto)
Using cached PyYAML-3.12.tar.gz
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 335, in run
wb.build(autobuilding=True)
File "/Library/Python/2.7/site-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 634, in _prepare_file
abstract_dist.prep_for_dist()
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 129, in prep_for_dist
self.req_to_install.run_egg_info()
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 412, in run_egg_info
self.setup_py, self.name,
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 387, in setup_py
import setuptools # noqa
File "/Library/Python/2.7/site-packages/setuptools/__init__.py", line 12, in <module>
import setuptools.version
File "/Library/Python/2.7/site-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 72, in <module>
import packaging.requirements
File "/Library/Python/2.7/site-packages/packaging/requirements.py", line 59, in <module>
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
TypeError: __call__() takes exactly 2 arguments (1 given)
所以有人知道我的 machine 是怎么回事吗?在安装 crypto 之前,我还需要安装任何其他软件包吗?
我目前正在使用 mac OS Y Yosemite 并且我的 pip 已升级。
************************更新****************** **********
这是原代码:
import threading
import paramiko
import subprocess
def ssh_command(ip,user,passwd,command):
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(ip,username = user, password = passwd)
ssh_session = client.get_transport().open_session()
if ssh_session.active:
ssh_session.exec_command(command)
print ssh_session.recv(1024)
return
ssh_command('192.168.100.301','GLZ','TripleBody','id')
希望这会有所帮助!
另外关于版本问题,我刚刚尝试使用pip安装pycrypto(这是2.6.1版本)并且出现了同样的错误。
在此先感谢您的大力帮助和耐心等待,
彼得
嘿,我遇到了同样的问题。
我尝试了以下说明并且有效! (由来自 https://bugs.centos.org/view.php?id=12722&history=1 的 ptmcg 提供)
This line in requirements.py of the packaging module:
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
使用 pyparsing 2.0.2 中引入的功能,特别是使用 "expr()" 复制表达式,在本例中为 "MARKER_EXPR()"。升级到 pyparsing 2.1.10(最新版本)是推荐的操作过程,但这也可以通过将 requirements.py 中的代码更改为:
来解决
MARKER_EXPR = originalTextFor(MARKER_EXPR)("marker")
(这一行其实不需要复制MARKER_EXPR。)
我最近正在尝试 运行 一段带有 paramiko 的代码,该代码只是构建一个基本的 ssh 端口并且可以在其他 machines 上使用该代码。但是,当我安装 paramiko 和 运行 我自己的代码 machine 时,它不起作用。我仔细检查了代码以确保它是相同的。然后我在编译时检查了错误,它说:
import paramiko
File "/Library/Python/2.7/site-packages/paramiko/__init__.py", line 30, in <module>
from paramiko.transport import SecurityOptions, Transport
File "/Library/Python/2.7/site-packages/paramiko/transport.py", line 33, in <module>
from cryptography.hazmat.backends import default_backend
File "/Library/Python/2.7/site-packages/cryptography/hazmat/backends/__init__.py", line 7, in <module>
import pkg_resources
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 72, in <module>
import packaging.requirements
File "/Library/Python/2.7/site-packages/packaging/requirements.py", line 59, in <module>
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
TypeError: __call__() takes exactly 2 arguments (1 given)
我在网上寻找答案,它说我可能遇到的问题是我没有 crypto 1.4.1 包。因此,我使用 pip 安装包,由于某种原因,我收到了与 运行 安装程序相同的错误。
pip install crypto
Collecting crypto
Using cached crypto-1.4.1-py2.py3-none-any.whl
Collecting shellescape (from crypto)
Using cached shellescape-3.4.1-py2.py3-none-any.whl
Collecting Naked (from crypto)
Using cached Naked-0.1.31-py2.py3-none-any.whl
Collecting requests (from Naked->crypto)
Using cached requests-2.13.0-py2.py3-none-any.whl
Collecting pyyaml (from Naked->crypto)
Using cached PyYAML-3.12.tar.gz
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 335, in run
wb.build(autobuilding=True)
File "/Library/Python/2.7/site-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 634, in _prepare_file
abstract_dist.prep_for_dist()
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 129, in prep_for_dist
self.req_to_install.run_egg_info()
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 412, in run_egg_info
self.setup_py, self.name,
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 387, in setup_py
import setuptools # noqa
File "/Library/Python/2.7/site-packages/setuptools/__init__.py", line 12, in <module>
import setuptools.version
File "/Library/Python/2.7/site-packages/setuptools/version.py", line 1, in <module>
import pkg_resources
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 72, in <module>
import packaging.requirements
File "/Library/Python/2.7/site-packages/packaging/requirements.py", line 59, in <module>
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
TypeError: __call__() takes exactly 2 arguments (1 given)
所以有人知道我的 machine 是怎么回事吗?在安装 crypto 之前,我还需要安装任何其他软件包吗?
我目前正在使用 mac OS Y Yosemite 并且我的 pip 已升级。
************************更新****************** **********
这是原代码:
import threading
import paramiko
import subprocess
def ssh_command(ip,user,passwd,command):
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(ip,username = user, password = passwd)
ssh_session = client.get_transport().open_session()
if ssh_session.active:
ssh_session.exec_command(command)
print ssh_session.recv(1024)
return
ssh_command('192.168.100.301','GLZ','TripleBody','id')
希望这会有所帮助!
另外关于版本问题,我刚刚尝试使用pip安装pycrypto(这是2.6.1版本)并且出现了同样的错误。
在此先感谢您的大力帮助和耐心等待, 彼得
嘿,我遇到了同样的问题。 我尝试了以下说明并且有效! (由来自 https://bugs.centos.org/view.php?id=12722&history=1 的 ptmcg 提供)
This line in requirements.py of the packaging module:
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
使用 pyparsing 2.0.2 中引入的功能,特别是使用 "expr()" 复制表达式,在本例中为 "MARKER_EXPR()"。升级到 pyparsing 2.1.10(最新版本)是推荐的操作过程,但这也可以通过将 requirements.py 中的代码更改为:
来解决MARKER_EXPR = originalTextFor(MARKER_EXPR)("marker")
(这一行其实不需要复制MARKER_EXPR。)