I've hit this weird issue were I'm unable to import from the math module in Python. However importing the entire module works.
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/Users/bdhammel/Documents/research_programming/analysis_routines/visar_analysis.py in <module>()
16
17 from core import scopes as cscopes
---> 18 from core import plot as cplot
19 from core.plot import ImageData, IndexSelector
20 from core.math import savitzky_golay
/Users/bdhammel/Documents/research_programming/core_diag/core/plot.py in <module>()
10 sys.path.append(CORE_DIR)
11
---> 12 from core import math as cmath
13
14 class ImageData(object):
/Users/bdhammel/Documents/research_programming/core_diag/core/math.py in <module>()
3 import sys
4 import math
----> 5 from math import factorial
6 from scipy.integrate import cumtrapz
7
ImportError: cannot import name factorial
My directory structure is something like this
Main file
from math import factorial # works fine here
import custom_module
custom_module
import math # works fine
from math import factorial # breaks
I have no idea why this could be. Any help would be appreciated.
I'm working inside of a virtual environment.
如果要在core.math
内导入内置math
,请打开绝对导入,这样就不会得到core.math
:
from __future__ import absolute_import
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.