Skip to content

Commit

Permalink
checkAndImport for Py3 and Py2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
karolamik13 committed Dec 17, 2024
1 parent 746f660 commit 943f34f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions prody/proteins/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,18 @@ def checkAndImport(package_name):
if not isinstance(package_name, str):
raise TypeError('package_name should be a string')

import importlib.util
if importlib.util.find_spec(package_name) is None:
LOGGER.warn("Package " + str(package_name) + " is not installed. Please install it to use this function.")
return False
if PY3K:
import importlib.util
if importlib.util.find_spec(package_name) is None:
LOGGER.warn("Package " + str(package_name) + " is not installed. Please install it to use this function.")
return False
else:
try:
__import__(package_name)
except ImportError:
LOGGER.warn("Package " + str(package_name) + " is not installed. Please install it to use this function.")
return False

return True

def getVmdModel(vmd_path, atoms):
Expand Down

0 comments on commit 943f34f

Please sign in to comment.