擅长:python、mysql、java
<p>您的代码在IDE中工作而不是在命令行中工作的原因可能是您在运行代码时所使用的Python环境上有所不同。在</p>
<p>我做了几个测试:</p>
<ol>
<li><p>安装了<code>eulexistdb</code>但<em>不是</em>Django的Virtualenv。<code>eulexistdb</code>尝试加载<code>django.conf</code>,但失败,因此不尝试从Django配置获取其配置。最终,您的代码运行时不会出错。</p></li>
<li><p>带有“eulexistdb<code>*and* Django:</code>eulexistdb<code>tries to load</code>的Virtualenvdjango.conf公司`成功了。然后,我尝试从Django配置获取is配置,但失败了。我得到了你在问题中描述的同样的错误。</p></li>
</ol>
<p>为了防止Django安装出现错误,可以像在<a href="https://stackoverflow.com/a/18265345/1906307">accepted self-answer</a>中那样添加Django配置来修复该问题。但是如果您正在编写的代码没有使用Django,那么这是一种让代码运行起来的迂回方式。解决这个问题最直接的方法是简单地在创建<code>ExistDB</code>实例的代码中添加一个<code>timeout</code>参数:</p>
<pre><code> self.db = db.ExistDB(
server_url="http://localhost:8080/exist", timeout=None)
</code></pre>
<p>如果你这样做,就不会有任何错误。将<code>timeout</code>设置为<code>None</code>将保留默认行为,但阻止<code>eulexistdb</code>查找Django配置。在</p>