Python ';pip安装';具有相同命名空间包的两个模块

Python ';pip安装';具有相同命名空间包的两个模块,python,pip,Python,Pip,我创建了两个控制盘,分别包含foo/comp1.py和foo/comp2.pyfoo'是一个名称空间包()。在同一文件夹中安装这两个包时,我希望pip将它们合并。但它失败了。这是预期的吗?为什么? 例如: pip_namespace>unzip -l comp1/dist/foo.comp1-1.0.0-py3-none-any.whl Archive: comp1/dist/foo.comp1-1.0.0-py3-none-any.whl Length Date T

我创建了两个控制盘,分别包含foo/comp1.py和foo/comp2.pyfoo'是一个名称空间包()。在同一文件夹中安装这两个包时,我希望pip将它们合并。但它失败了。这是预期的吗?为什么?

例如:

pip_namespace>unzip -l comp1/dist/foo.comp1-1.0.0-py3-none-any.whl
Archive:  comp1/dist/foo.comp1-1.0.0-py3-none-any.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2016-01-27 14:45   foo/comp1.py
       31  2016-01-27 14:55   foo.comp1-1.0.0.dist-info/DESCRIPTION.rst
      377  2016-01-27 14:55   foo.comp1-1.0.0.dist-info/metadata.json
        4  2016-01-27 14:55   foo.comp1-1.0.0.dist-info/top_level.txt
       92  2016-01-27 14:55   foo.comp1-1.0.0.dist-info/WHEEL
      244  2016-01-27 14:55   foo.comp1-1.0.0.dist-info/METADATA
      568  2016-01-27 14:55   foo.comp1-1.0.0.dist-info/RECORD
---------                     -------
     1316                     7 files

pip_namespace>unzip -l comp2/dist/foo.comp2-1.0.0-py3-none-any.whl
Archive:  comp2/dist/foo.comp2-1.0.0-py3-none-any.whl
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2016-01-27 14:56   foo/comp2.py
       31  2016-01-27 14:57   foo.comp2-1.0.0.dist-info/DESCRIPTION.rst
      377  2016-01-27 14:57   foo.comp2-1.0.0.dist-info/metadata.json
        4  2016-01-27 14:57   foo.comp2-1.0.0.dist-info/top_level.txt
       92  2016-01-27 14:57   foo.comp2-1.0.0.dist-info/WHEEL
      244  2016-01-27 14:57   foo.comp2-1.0.0.dist-info/METADATA
      568  2016-01-27 14:57   foo.comp2-1.0.0.dist-info/RECORD
---------                     -------
     1316                     7 files

pip_namespace>pip install -t test_pip comp1/dist/foo.comp1-1.0.0-py3-none-any.whl
Processing ./comp1/dist/foo.comp1-1.0.0-py3-none-any.whl
Installing collected packages: foo.comp1
Successfully installed foo.comp1
You are using pip version 7.1.2, however version 8.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

pip_namespace>pip install -t test_pip comp2/dist/foo.comp2-1.0.0-py3-none-any.whl
Processing ./comp2/dist/foo.comp2-1.0.0-py3-none-any.whl
Installing collected packages: foo.comp2
Successfully installed foo.comp2
Target directory /remote/devsup/users/flemaitre/tmp/pip_namespace/test_pip/foo already exists. Specify --upgrade to force replacement.
You are using pip version 7.1.2, however version 8.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
因此,comp2缺失:

pip_namespace>find test_pip/foo
test_pip/foo
test_pip/foo/__pycache__
test_pip/foo/__pycache__/comp1.cpython-35.pyc
test_pip/foo/comp1.py

我想你可以在这里找到答案:

使用这个答案,我能够在同一顶级命名空间中部署两个控制盘