导入语句导致dist包中的问题

时间:2015-07-01 05:37:15

标签: python

我从这个git存储库安装了vnfmanager。安装顺利

https://github.com/TCS-TelcoCloud/vnfmanager.git

软件包安装在

目录下
/usr/local/lib/python2.7/dist-packages/

vnfmanager-2015.1.0-py2.7.egg
          |
          |---- vnfmanager (Folder)
                 |
                 |---- vnf_manager.py

主要功能位于vnf_manager.py。

安装后,当我启动服务时,出现以下错误

Traceback (most recent call last):
  File "/usr/local/bin/vnf-manager", line 9, in <module>
    load_entry_point('vnfmanager==2015.1.0', 'console_scripts', 'vnf-manager')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 357, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2478, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2192, in load
    ['__name__'])
ImportError: No module named vnf_manager

因此,我使用PDB来查找发生异常的地方。这让我直到

pdb /usr/local/bin/vnf-manager --config-file /etc/vnfsvc/vnfsvc.conf --vnfm-conf-dir /var/lib/vnfsvc/78c1f834-fd4f-4fba-b15e-42707a501fcd/ --log-file /var/lib/vnfsvc/78c1f834-fd4f-4fba-b15e-42707a501fcd/vnfm.log --uuid 78c1f834-fd4f-4fba-b15e-42707a501fcd
> /usr/local/bin/vnf-manager(3)<module>()
-> __requires__ = 'vnfmanager==2015.1.0'
(Pdb) b /usr/lib/python2.7/dist-packages/pkg_resources.py:2190
Breakpoint 1 at /usr/lib/python2.7/dist-packages/pkg_resources.py:2190
(Pdb) c
vnfmanager 2015.1.0 ------------DIST-------
> /usr/lib/python2.7/dist-packages/pkg_resources.py(2190)load()
-> print self.module_name, "-------------self.module_name---------------"
(Pdb) print self.module_name
vnfmanager.vnf_manager
(Pdb) c
vnfmanager.vnf_manager -------------self.module_name---------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/pdb.py", line 1314, in main
    pdb._runscript(mainpyfile)
  File "/usr/lib/python2.7/pdb.py", line 1233, in _runscript
    self.run(statement)
  File "/usr/lib/python2.7/bdb.py", line 400, in run
    exec cmd in globals, locals
  File "<string>", line 1, in <module>
  File "/usr/local/bin/vnf-manager", line 9, in <module>
    load_entry_point('vnfmanager==2015.1.0', 'console_scripts', 'vnf-manager')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 357, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2480, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.

导致错误的文件是/usr/lib/python2.7/dist-packages/pkg_resources.py。和发生异常的行是

 print self.module_name, "-------------self.module_name---------------"
        entry = __import__(self.module_name, globals(), globals(),
            ['__name__'])

 print entry, "-----------------------ENTRY--------------------------"


self.module_name contains - vnfmanager.vnf_manager
__name__ contains - pkg_resources

我不太确定,为什么模块没有导入,即使它存在于路径中。

在另一台服务器上,相同的代码正常运行。请帮忙

编辑:

尝试使用virtualenv进行安装。仍然得到同样的错误。

(test3)nfv@nfv-controller-2:~/nfvorch/test/vnfmanager$ /usr/local/bin/vnf-manager --config-file /etc/vnfsvc/vnfsvc.conf --vnfm-conf-dir /var/lib/vnfsvc/78c1f834-fd4f-4fba-b15e-42707a501fcd/ --log-file /var/lib/vnfsvc/78c1f834-fd4f-4fba-b15e-42707a501fcd/vnfm.log --uuid 78c1f834-fd4f-4fba-b15e-42707a501fcd
vnfmanager 2015.1.0 ------------DIST-------
vnfmanager.vnf_manager -------------self.module_name---------------
Traceback (most recent call last):
  File "/usr/local/bin/vnf-manager", line 9, in <module>
    load_entry_point('vnfmanager==2015.1.0', 'console_scripts', 'vnf-manager')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 357, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2480, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2192, in load
    ['__name__'])
ImportError: No module named vnf_manager

0 个答案:

没有答案