我需要导入src库.我用过pip-install-src.但是出现了错误用法



我正在使用Colab笔记本构建分割模型。我需要导入src库。我用过pip install src。但是出现了一个错误,我已经在磁盘上下载了软件包,但我不知道如何将其插入笔记本上使用。

错误

Downloading https://files.pythonhosted.org/packages/9a/2b/a6ccfc80af698319c54f00da05f6c798cf72291938893f8bd3f730c2daf9/src-0.0.7.zip
Building wheels for collected packages: src
Building wheel for src (setup.py) ... error
ERROR: Failed building wheel for src
Running setup.py clean for src
Failed to build src
Installing collected packages: src
Running setup.py install for src ... error
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-o7x6uewa/src/setup.py'"'"'; __file__='"'"'/tmp/pip-install-o7x6uewa/src/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-e8u3fix1/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

尝试pip install src==0.0.6

它对我有效

我需要导入src库。

不,你没有。pypi中有一个名为src的包,它是由一个善良的灵魂设计的,因为这不是你想做的。


当您被指示使用pip install src时,这意味着您应该将目录src作为本地包安装在本地存储库下。如果这个命令不起作用,那是因为你在错误的目录中运行它,你跳过了下载你试图安装的程序的源代码,或者你没有从mantainer中读取一些指令。

以这种方式构建的程序包具有定义良好的setup.pysetup.cfgpyproject.toml和所有模块,这些模块都卡在src文件夹中,只需将pip install src写入程序源代码的根文件夹,就可以轻松地将整个程序安装为python程序包(或模块(。

如果没有一个src文件夹被正确配置为python包或模块,pip将默认在pypi默认存储库(pypi.org(上搜索名为src的包。谢天谢地,有人决定在该命名空间上制作一个虚拟包,以避免有人将病毒上传到您的环境中,让你的代码不起作用,这样你就可以避免做一些你不应该做的事情。

因此,要修复这种不希望出现的行为,您应该确保要安装的软件包存在于您的环境中。对于云环境,运行pip install src的当前文件夹应该是下载要安装的东西的源文件的文件夹。

最新更新