我有一个私有模块,无论好坏,我都调用了time
. 我有另一个模块,我称之为graph
驻留在它使用该redis-py
模块的同一目录中。
不幸的是,我的time
模块并不完全符合标准time
模块的功能,因此我收到以下错误:
$ /opt/stuff/bin/python /opt/stuff/lib/utils/graph.py
Traceback (most recent call last):
File "/opt/stuff/lib/utils/graph.py", line 6, in <module>
import redis
File "/opt/stuff/lib/python2.6/site-packages/redis/__init__.py", line 1, in <module>
from redis.client import Redis, StrictRedis
File "/opt/stuff/lib/python2.6/site-packages/redis/client.py", line 6, in <module>
import time as mod_time
File "/opt/stuff/lib/utils/time.py", line 5, in <module>
import pytz
File "/usr/lib/python2.6/site-packages/pytz/__init__.py", line 32, in <module>
from pkg_resources import resource_stream
File "/opt/stuff/lib/python2.6/site-packages/pkg_resources.py", line 761, in <module>
class Environment(object):
File "/opt/stuff/lib/python2.6/site-packages/pkg_resources.py", line 764, in Environment
def __init__(self, search_path=None, platform=get_supported_platform(), python=PY_MAJOR):
File "/opt/stuff/lib/python2.6/site-packages/pkg_resources.py", line 140, in get_supported_platform
plat = get_build_platform(); m = macosVersionString.match(plat)
File "/opt/stuff/lib/python2.6/site-packages/pkg_resources.py", line 282, in get_build_platform
from distutils.util import get_platform
File "/opt/stuff/lib64/python2.6/distutils/__init__.py", line 25, in <module>
from distutils import dist, sysconfig
File "/usr/lib64/python2.6/distutils/dist.py", line 21, in <module>
from distutils.fancy_getopt import FancyGetopt, translate_longopt
File "/usr/lib64/python2.6/distutils/fancy_getopt.py", line 32, in <module>
longopt_xlate = string.maketrans('-', '_')
AttributeError: 'module' object has no attribute 'maketrans'
删除我的time
模块可以纠正错误。有没有办法让我graph.py
基本上忽略我的time
模块并使用系统模块?我试过使用from __future__ import absolute_import
,但这似乎没有什么不同。