草庐IT

pkg_resources

全部标签

java - src/main/resources 中的 FileNotFoundException

我在我的maven项目中放置了一个文件在src/main/resources下文件名只是temp.txt。当我尝试打开文件时:BufferedReaderbr=newBufferedReader(newFileReader(newFile("./temp.txt")));我得到一个错误:Exceptioninthread"main"java.io.FileNotFoundException:\temp.txtsrc/main/resources下的所有文件都放在根目录下maven下的类路径。那么为什么程序不能在这里找到文件呢? 最佳答案

java - 通过 Resource 读写 Java 文件

我正在尝试读取和写入文件,但我想通过资源访问该文件。我就是这样Filef=newFile(ClassLoader.getSystemResource("/blah/blah/Properties.prop").toURI());BufferedReaderbr=newBufferedReader(newFileReader(f));Stringline=br.readLine();PrintWriterp=newPrintWriter(newFile(ClassLoader.getSystemResource("/blah/blah/Properties.prop").toURI())

java - 如何更改默认 Eclipse WTP "Web Resources"动态文件夹

我需要更改默认的EclipseWTP“Web资源”动态文件夹。目前它指向WebContent,我需要指向src\main\webapp。 最佳答案 我找到了解决方案:在项目文件夹的.settings文件夹下,有一个名为“org.eclipse.wst.common.component”的文件,在其中更改行与.就是这样! 关于java-如何更改默认EclipseWTP"WebResources"动态文件夹,我们在StackOverflow上找到一个类似的问题:

python - 损坏的 pip3 和 easy_install3 : DistributionNotFound

我的pip3好像坏了:$pip3--versionTraceback(mostrecentcalllast):File"/usr/bin/pip3",line5,infrompkg_resourcesimportload_entry_pointFile"/usr/lib/python3/dist-packages/pkg_resources.py",line2708,inworking_set.require(__requires__)File"/usr/lib/python3/dist-packages/pkg_resources.py",line686,inrequireneede

python - OSError : [Errno 11] Resource temporarily unavailable. 这是什么原因造成的?

背景我有两个需要相互通信的python进程。通信由名为Pipe的类处理。我为此创建了一个单独的类,因为大部分需要交流的信息都以字典的形式出现,因此Pipe实现了一个非常简单的协议(protocol)来执行此操作。这是管道构造函数:def__init__(self,sPath):"""createthefifo.ifitalreadyexistsjustassociatewithit"""self.sPath=sPathifnotos.path.exists(sPath):try:os.mkfifo(sPath)except:raiseException('cannotmkfifoatp

Python 错误 : "socket.error: [Errno 11] Resource temporarily unavailable" when sending image

我想制作一个程序,从文件中访问图像,对它们进行编码,然后将它们发送到服务器。比服务器应该解码图像,并将其保存到文件中。我测试了图像编码本身,它有效,所以问题出在服务器和客户端连接上。这是服务器:importsocketimporterrnoimportbase64fromPILimportImageimportStringIOdefconnect(c):try:image=c.recv(8192)returnimageexceptIOErrorase:ife.errno==errno.EWOULDBLOCK:connect(c)defMain():host='138.106.180.2

Python:如果安装了同一个包的多个 egg 版本,我该如何具体导入我需要的版本?

例如,FooPackage-1.1和FooPackage-1.2都作为egg安装在dist-packages中。如何导入我需要的? 最佳答案 您可以使用pkg_resources在导入时指定您的要求:importpkg_resourcespkg_resources.require('FooPackage==1.2')importFooPackage例如:%easy_installsimplejson==2.1.3%easy_installsimplejson==2.1.2pkg_resources.require('simplejs

python - pkg_resources.resource_stream 在 python3 上失败

我正在尝试使用pkg_resources加载我的项目中存在的资源,但它只是抛出一个异常,说它引用了“无法为没有'的加载程序执行此操作get_data()'"。我不确定我是否在这里做错了什么,或者pkg_resources在python3.3上是否以某种方式被破坏了。确切地说,我使用的是python3.3.3。这是我要执行的代码>>>importpkg_resources>>>data=pkg_resources.resource_stream('configgenerator','schema_rules.yml')Traceback(mostrecentcalllast):File"

python - 从 egg 内部访问 python egg 中的文件

问题是试图获得关于如何做到这一点的确切说明。之前尝试的很少,似乎不是完整的解决方案:solutiontomovethefileinsidethepackagesolutiontoreadaszipaccessingmetainfoviaget_distribution手头的任务是读取有关运行程序的egg的信息。据我了解,有几种方法:对egg的位置进行硬编码并将其视为zip存档-可以工作,但不够灵活,因为如果文件移动到另一个位置,则需要对其进行编辑和重新编译使用ResourceManager().resource_filename(__name__,filename)-这似乎是有限的,因

python - 找不到 "six",但已安装

我安装了六个(甚至重新安装了它)。$pipshowsix---Name:sixVersion:1.7.3Location:/usr/lib/python2.6/site-packagesRequires:但是当我尝试运行csvcut时,它找不到它。$csvcut-nmonster.csvTraceback(mostrecentcalllast):File"/usr/bin/csvcut",line5,infrompkg_resourcesimportload_entry_pointFile"/usr/lib/python2.6/site-packages/pkg_resources.p