为什么在Python3中加载模块有问题而在Python2中没有?
根据我使用的Python版本,我在加载一个模块时遇到了一些问题。当我在终端输入
from quantecon import approx_markov
并使用Python 3.4.0时,出现了以下错误信息:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/quantecon/__init__.py", line 6,in <module>
from asset_pricing import AssetPrices
ImportError: No module named 'asset_pricing'
在上面提到的文件夹/usr/...中,我确实找到了一个叫asset_pricing
的模块。(我得承认,我也不明白为什么这个模块asset_pricing
会有干扰。)
我通过以下命令安装了quantecon
:
pip3 install quantecon
我怀疑这些问题和我使用的Python版本有关。我还安装了
pip install quantecon
当我在终端中使用Python 2.7.6(我认为这是我使用的操作系统的标准Python版本)调用模块approx_markov
时,并没有收到任何错误信息。为了解决这个问题,我已经按照以下讨论中的说明操作过,但没有成功:Python3无法访问Python2模块(ubuntu)。