paramiko安装问题解决方案

paramiko安装

我当电脑安装的是python3.6.5版本,需要安装paramiko进行远程服务器操作所以选择安装paramiko模块。

通过命令:pip install paramiko进行安装报错,报错内容如下:

  Running setup.py install for bcrypt ... error
    Complete output from command D:\work\wy_only\robot_fw\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-zg20xq06\\bcrypt\\setup.py';f=getattr(tokenize,
'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\ADMINI~1\AppData\Local\Temp\pip-record-jy1fhtl0\install-record.txt --single-version-externally-
managed --compile --install-headers D:\work\wy_only\robot_fw\venv\include\site\python3.6\bcrypt:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.6
    creating build\lib.win-amd64-3.6\bcrypt
    copying src\bcrypt\__about__.py -> build\lib.win-amd64-3.6\bcrypt
    copying src\bcrypt\__init__.py -> build\lib.win-amd64-3.6\bcrypt
    copying src\bcrypt\py.typed -> build\lib.win-amd64-3.6\bcrypt
    running build_ext
    generating cffi module 'build\\temp.win-amd64-3.6\\Release\\_bcrypt.c'
    creating build\temp.win-amd64-3.6
    creating build\temp.win-amd64-3.6\Release
    building '_bcrypt' extension
    error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

    ----------------------------------------

Command "D:\work\wy_only\robot_fw\venv\Scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-install-zg20xq06\\bcrypt\\setup.py';f=getattr(tokenize, 'open', open)(__file__);
code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\ADMINI~1\AppData\Local\Temp\pip-record-jy1fhtl0\install-record.txt --single-version-externally-managed --compile --inst
all-headers D:\work\wy_only\robot_fw\venv\include\site\python3.6\bcrypt" failed with error code 1 in C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-zg20xq06\bcrypt\
You are using pip version 10.0.1, however version 20.3b1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

解决方案1:

此方案由同事提供,我并未实践。

​ 1.安装版本更高的的Microsoft Visual C++版本,安装包见百度磁盘链接

​ 2.安装paramiko

命令:pip install paramiko

解决方案2:

​ 1.安装pycrypto-2.6.1-cp36-cp36m-win_amd64.whl,安装包见百度磁盘链接

命令: pip install pycrypto-2.6.1-cp36-cp36m-win_amd64.whl

​ 2.安装bcrypt==3.1.7

命令:pip install bcrypt==3.1.7

3.安装paramiko==2.4.1

命令:pip install paramiko==2.4.1

下载

下载Microsoft Visual C++,pycrypto-2.6.1-cp36-cp36m-win_amd64.whl见下列百度磁盘地址:
https://pan.baidu.com/s/174lIOeNd9m1WNBqNrL62cQ 提取码:rbll

简单的文件上传代码:

 def load_file_to_service(local_path, remote_path):
    """
    :param local_path: 本地路径,格式如: "d:\\dd.txt"
    :param remote_path: 远程路径  格式如:"/root/file/dd.txt"
    """
    t = paramiko.Transport('192.111.103.153', 22)  
    //192.111.103.153:服务器地址 22:端口
    t.connect(username='admin', password='123456')
    //admin:服务器账号,123456:账号密码
    sftp = paramiko.SFTPClient.from_transport(t)
    sftp.put(local_path, remote_path)  # 上传文件到远程机
    sftp.close()

你可能感兴趣的:(python,python,linux)