Python模块错误

0 投票
2 回答
1524 浏览
提问于 2025-05-10 23:00

你好,我是Python的新手,我想使用一个已经开发好的工具/代码,但我在使用的模块上遇到了问题。

我通过Anaconda安装了Spider这个工具。

我正在尝试运行下面的代码,
https://code.google.com/p/quantandfinancial/source/browse/trunk/example_black_litterman.py

如果我理解得没错,这段代码引用了下面这个自定义模块:https://code.google.com/p/quantandfinancial/source/browse/trunk/structures/quote.py?r=25

我把这两部分代码存放在 C:\Users\Michal\Documents\Python Scripts 这个文件夹里,而Python安装在 C:\Anaconda3 里。当我运行代码时,出现了一个错误。

File "C:/Users/Michal/Documents/Python Scripts/Black-Litterman.py", line 4, in <module>
    from structures.quote import QuoteSeries
ImportError: No module named 'structures'

请帮忙,我该如何让这段代码运行起来呢?

相关文章:

  • 暂无相关问题
暂无标签

2 个回答

0

你需要这样做:

pip install structures

最好的办法可能是先创建一个conda环境,这样你就可以在里面管理所有需要的包了。

1

在普通的Windows命令提示符下,输入pip install structures对我来说是有效的。

C:\Users\user>pip install structures

你现在使用的pip版本是7.0.3,但有更新的版本7.1.2可以使用。你可以考虑通过输入'python -m pip install --upgrade pip'来升级。

> Collecting structures   
> Downloading structures-2.0.2.tar.bz2
> Installing collected packages: structures   
> Running setup.py install for structures 
> Successfully installed structures-2.0.2

撰写回答