用java实现sftp下载,报2: No such file

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用java实现sftp下载,报2: No such file相关的知识,希望对你有一定的参考价值。

导入jsch的包实现sftp下载,运行时:

是什么原因?怎么解决
我想要下载D盘下aaa文件夹下的abc.txt文件,保存在D盘下tmp文件夹下
SftpDownload sf = new SftpDownload();
String host = "127.0.0.1";
int port = 9999;
String username = "root";
String password = "root";
String directory = "/home/httpd/test/";
String downloadFile = "abc.txt";
String saveFile = "D:\\tmp\\download.txt";
这些地址写的对么?directory 应该写什么?服务器就是本机,用户名和密码正确

参考技术A 那就是no such file
文件不存在本回答被提问者采纳

virtualenv中执行python脚本报错ImportError: No module named markupsafe 或 No such file or directory: '/tm

2env为我使用virtualen创建的虚拟python环境,我的本地要使用的各类库已下载到文件夹lianxi下面,ceshi2.txt为我要安装的各类库包列表

(2env) [root@xxxxxxx]$ ./2env/bin/python wsgi.py
Traceback (most recent call last):
File "wsgi.py", line 12, in <module>
from rrd import app
File "/xxxx/rrd/__init__.py", line 4, in <module>
from flask import Flask, request, Blueprint
File "/xxxxx/2env/lib/python2.7/site-packages/flask/__init__.py", line 19, in <module>
from jinja2 import Markup, escape
File "/xxxxx/2env/lib/python2.7/site-packages/jinja2/__init__.py", line 33, in <module>
from jinja2.environment import Environment, Template
File "/xxxxx/2env/lib/python2.7/site-packages/jinja2/environment.py", line 13, in <module>
from jinja2 import nodes
File "/xxxxxx/2env/lib/python2.7/site-packages/jinja2/nodes.py", line 18, in <module>
from jinja2.utils import Markup
File "/xxxxx/2env/lib/python2.7/site-packages/jinja2/utils.py", line 520, in <module>
from markupsafe import Markup, escape, soft_unicode
ImportError: No module named markupsafe
解决办法:
在目录/xxxx/2env/lib/python2.7/site-packages 下确实没有发现markupsafe,需要重新安装,见下面的解决办法
单独重新安装:pip install --no-index --find-links=lianxi -r ./ceshi2.txt --target=2env/lib/python2.7/site-packages
但是执行会出错,见问题2

问题2:
(2env) [root@xxxxx]$ pip install --no-index --find-links=lianxi -r ./ceshi2.txt --target=2env/lib/python2.7/site-packages
Ignoring indexes: https://pypi.python.org/simple
Collecting MarkupSafe==1.1.1 (from -r ./ceshi2.txt (line 1))
Installing collected packages: MarkupSafe
Successfully installed MarkupSafe-1.1.1
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 366, in run
for item in os.listdir(lib_dir):
OSError: [Errno 2] No such file or directory: ‘/tmp/tmp0lEZD9/lib/python‘

解决办法:增加一行lib_dir = lib_dir.replace("lib","lib64")在/usr/lib/python2.7/site-packages/pip/commands/install.py中,增加的位置如下:
if options.target_dir:
ensure_dir(options.target_dir)

lib_dir = distutils_scheme(‘‘, home=temp_target_dir)[‘purelib‘]
lib_dir = lib_dir.replace("lib","lib64")       <---------------增加到此处
for item in os.listdir(lib_dir):
target_item_dir = os.path.join(options.target_dir, item)
if os.path.exists(target_item_dir):
if not options.upgrade:

 

以上是关于用java实现sftp下载,报2: No such file的主要内容,如果未能解决你的问题,请参考以下文章

xmanager运行报错:bash: /usr/bin/xterm: No such file or directory

libsodium引用报错FileNotFoundError: [Errno 2] No such file or directory: b‘liblibsodium.a‘

YCSB报": No such file or directory"异常

centos7数据库连接使用127.0.0.1报permission denied,使用localhost报No such file or directory

Jenkins打包报错:(No such file or directory) and 'parent.relativePath' points at no local POM

virtualenv中执行python脚本报错ImportError: No module named markupsafe 或 No such file or directory: '/tm