无法在全球范围内安装私有软件包

时间:2019-01-21 21:07:30

标签: python python-2.7

我刚刚开发了一个自定义程序包,打算将其提供给某些客户。
我使用python setup.py sdist构建了程序包,这些是我的setup.py文件的内容:

import os
from setuptools import setup, find_packages
from distutils.util import convert_path

main_ns = {}
ver_path = convert_path(os.path.dirname(os.path.abspath(__file__)) + '/version.py')

try:
    with open(ver_path) as ver_file:
        exec (ver_file.read(), main_ns)
except IOError:
    main_ns['__version__'] = '0.0.0'

setup(name='foobbar',
      version=main_ns['__version__'],
      description='SomeDescription',
      license='GPL',
      packages=find_packages(),
      zip_safe=True,
      install_requires=[
          'packaging',
          'Pillow',
          'requests',
          'pyserial'
      ],
      extras_require={
            'picamera': ['picamera']
      }
      )

一切都正确构建。当我尝试安装它时,会发生问题。我解压缩所有内容,进入包文件夹并运行python setup.py install --user。查看输出,一切似乎都很好。如果启动python控制台,则可以导入模块 BUT (如果更改目录,则会出现导入错误)。

怎么回事?
这是我第一次创建软件包,所以很可能我做错了什么。

我检查了我的本地目录,看来该模块在那里:

$ ll .local/lib/python2.7/site-packages/
... snip ...
-rw-rw-r--  1 tampe125 tampe125  32K gen 19 23:09 foobar-0.0.2-py2.7.egg

我检查了sys.path属性,并且我的本地目录在那里:

>>> import sys
>>> from pprint import pprint
>>> pprint(sys.path)
['',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/home/tampe125/.local/lib/python2.7/site-packages',
 '/usr/local/lib/python2.7/dist-packages/pyserial-3.4-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/Pillow-5.4.1-py2.7-linux-x86_64.egg',
 '/home/tampe125/.local/lib/python2.7/site-packages/packaging-18.0-py2.7.egg',
 '/home/tampe125/.local/lib/python2.7/site-packages/pyparsing-2.3.1-py2.7.egg',
 '/home/tampe125/.local/lib/python2.7/site-packages/foobar-0.0.2-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/local/lib/python2.7/dist-packages/setuptools-39.1.0-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/picamera-1.13-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/PyYAML-4.2b4-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/iso8601-0.1.12-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/future-0.17.1-py2.7.egg',
 '/usr/lib/python2.7/dist-packages/gtk-2.0']

我想念什么?
P.s.显然,模块的名称不是foobar,我只是编辑了它。

0 个答案:

没有答案