Bug #2173
ping import failing
Start date:
12/16/2017
Due date:
% Done:
100%
Description
Traceback (most recent call last): File "ping.py", line 17, in <module> from network_tools_app.ping_network import ping_all File "/opt/splunk/etc/apps/network_tools/bin/network_tools_app/ping_network.py", line 9, in <module> from modular_input.contrib import ipaddress ImportError: No module named contrib
Associated revisions
Fixing failed import
Reference #2173
History
#1 Updated by Luke Murphey almost 7 years ago
Odd, this works:
import os import sys sys.path.insert(0, 'modular_input.zip') from modular_input.contrib import ipaddress
#2 Updated by Luke Murphey almost 7 years ago
- Status changed from New to Closed
- % Done changed from 0 to 100
Observations:
- This works on Mac for some reason; but not on Windows and Linux
- You can import things like "Field" but not from the contrib directory #
- Does making the path absolute make it work?
- No
- Is the modular input library valid\
- Can fields be imported
- No: this fails: from modular_input.fields import Field
- Does zipimport work? https://pymotw.com/2/zipimport/
- Yes
path_to_mod_input_lib = os.path.join(os.path.dirname(os.path.abspath(file)), '../modular_input.zip')
import zipimport
importer = zipimport.zipimporter(path_to_mod_input_lib)
modular_input = importer.load_module('modular_input')