简体   繁体   English

命名空间包冲突

[英]Namespace package conflict

I have a package that I'm working on ( LDB_Algebra ). 我有一个正在使用的软件包( LDB_Algebra )。 It has an extra that depends on another package that I created ( LDB_LAPACK ). 它有一个额外的依赖于我创建的另一个包( LDB_LAPACK )。 I have created a virtualenv and installed each of these packages as shown: 我创建了一个virtualenv并安装了以下每个软件包:

$ virtualenv -p pypy ve_pypy
$ . ve_pypy/bin/activate
(ve_pypy) $ pip install LDB_LAPACK
...
(ve_pypy) $ python setup.py install
... (Installs LDB_Algebra)

Each has the following for its __init__.py file under the ldb package: 每个文件在ldb软件包下的__init__.py文件都有以下内容:

__import__('pkg_resources').declare_namespace(__name__)

Problem: 问题:

The trouble is that when I try to use ldb.algebra it reports that it can't find the package. 麻烦在于,当我尝试使用ldb.algebra它报告找不到软件包。 Just to make sure it hasn't completely lost everything I attempt to import ldb.lapack and that works fine. 只是为了确保它没有完全丢失我尝试导入ldb.lapack所有内容,并且一切正常。 This suggests to me that I'm having a namespace package problem. 这向我表明我遇到了名称空间包问题。 It seems a similar question has been asked here (with no answer sadly). 似乎在这里提出了类似的问题(可悲的是没有答案)。 Upon investigating the directory structure of my virtualenv I find that under ve_pypy/site-packages/ there is a folder for the ldb namespace package which includes the lapack package but not the algebra package. 在研究我的virtualenv的目录结构后,我发现在ve_pypy/site-packages/有一个用于ldb名称空间包的文件夹,其中包括lapack包,但没有algebra包。 I also see an egg file, LDB_Algebra-0.3.2-py2.7.egg . 我还看到了一个鸡蛋文件LDB_Algebra-0.3.2-py2.7.egg Inside this egg file in the ldb directory is an __init__.py file with the appropriate namespace declaration (as above). ldb目录中的egg文件中,是一个__init__.py文件,带有相应的名称空间声明(如上所述)。 Presumably this is supposed to be where it gets the ldb.algebra package from but it's not looking there. 大概这应该是从那里获取ldb.algebra包的地方,但是它不在那儿。

Questions: 问题:

  1. Can anyone confirm with a reference that what I'm seeing is a known issue (ie that I'm not just doing some slightly wrong that's causing all these troubles)? 任何人都可以参考我所看到的是一个已知问题(即,我不只是在做一些导致所有这些麻烦的小错误)来确认吗? Are eggs and w/e the pip install method created (the ldb package directory under site-packages ) fundamentally incompatible? 创建的ldb和w / e pip安装方法( site-packages下的ldb package目录)是否根本不兼容?

  2. Assuming that the answer to the first question is that my method of package installing is fundamentally flawed, is there an easier way of installing the LDB_LAPACK package from pypi and the LDB_Algebra package from my local directory? 假设回答第一个问题是,我的包安装的方法是根本性的缺陷,有没有安装更简单的方法LDB_LAPACK一封来自PyPI包和LDB_Algebra从我的本地目录包? I'm not a setuptools wiz or anything so the answer may be very straightforward (don't overlook the obvious). 我不是setuptools wiz或其他任何人,因此答案可能非常简单(不要忽略明显的地方)。

Apparently this is a well known problem . 显然,这是一个众所周知的问题 The solution that was suggested to me and seems to work fine is to use pip install . 向我建议并似乎可以正常使用的解决方案是使用pip install . instead of python setup.py install . 而不是python setup.py install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM