当pip安装由于无空间错误而无法下载软件包时,我遇到了pip问题。在调查的同时,我尝试通过将软件包下载到set文件夹,然后使用以下方法进行脱机安装来设置解决方法:
pip download --no-cache-dir tensorflow -b /home/profile1/tmp/
在我的研究中,我发现pip默认使用根/tmp
文件夹,并且在成功安装后将其清除。因此,我将其设置为转到/tmp
目录下的另一个/profile1
文件夹。该命令似乎可以正常运行,但是当我查看目录时它是空的。我排除了通过再次运行它(这次打开一个新的终端)不会下载软件包的方法。下载tensorflow时,我导航到/profile1/tmp
并使用了ls
。该软件包及其相关软件包已下载-但是,一旦下载完成(使用ls -ltra
确认),它们就会消失。我相信它们会被移动,因为当我使用df -h /home
时,使用的空间有所增加。我需要能够将它们保存在/ tmp文件夹中进行安装。任何帮助将不胜感激。
编辑: 我尝试使用@sinoroc答案,虽然它适用于下载,但仍然崩溃,没有空间错误:
pip download --no-cache-dir tensorflow -d /home/profile1/tmp/
#downloads several packages
Traceback (most recent call last):
File "/home/profile1/anaconda3/envs/testinstall/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 186, in _main
status = self.run(options, args)
File "/home/profile1/anaconda3/envs/testinstall/lib/python3.6/site-packages/pip/_internal/commands/download.py", line 135, in run
resolver.resolve(requirement_set)
File "/home/profile1/anaconda3/envs/testinstall/lib/python3.6/site-packages/pip/_internal/legacy_resolve.py", line 177, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "/home/profile1/anaconda3/envs/testinstall/lib/python3.6/site-packages/pip/_internal/legacy_resolve.py", line 333, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/home/profile1/anaconda3/envs/testinstall/lib/python3.6/site-packages/pip/_internal/legacy_resolve.py", line 282, in _get_abstract_dist_for
abstract_dist = self.preparer.prepare_linked_requirement(req)
File "/home/profile1/anaconda3/envs/testinstall/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 482, in prepare_linked_requirement
hashes=hashes,
File "/home/profile1/anaconda3/envs/testinstall/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 287, in unpack_url
hashes=hashes,
File "/home/profile1/anaconda3/envs/testinstall/lib/python3.6/site-packages/pip/_internal/operations/prepare.py", line 164, in unpack_http_url
unpack_file(from_path, location, content_type)
File "/home/profile1/anaconda3/envs/testinstall/lib/python3.6/site-packages/pip/_internal/utils/unpacking.py", line 252, in unpack_file
flatten=not filename.endswith('.whl')
File "/home/profile1/anaconda3/envs/testinstall/lib/python3.6/site-packages/pip/_internal/utils/unpacking.py", line 139, in unzip_file
shutil.copyfileobj(fp, destfp)
File "/home/profile1/anaconda3/envs/testinstall/lib/python3.6/shutil.py", line 82, in copyfileobj
fdst.write(buf)
OSError: [Errno 28] No space left on device
使用`df -h / home'时,我看到文件系统中还有20 GB的空间。就补救而言,我还能做些其他事情吗?
编辑2:
我能够确认这只是点子。我能够使用conda install
来获取tensorflow,但不能获取pip。
答案 0 :(得分:1)
好像您正在寻找--dest <dir>
选项。
$ pip download --help
[...]
-d, --dest <dir> Download packages into <dir>.
https://pip.pypa.io/en/stable/reference/pip_download/#cmdoption-d