在python中导入模块时出现以下错误。我正在使用jupyter笔记本(python 2)。我通过互联网搜索但仍然无法弄清楚原因。任何帮助都会非常感激。
以下是代码:
import numpy as np
from pandas import Series,DataFrame
import pandas as pd
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-e4e9959b303a> in <module>()
----> 1 import numpy as np
2 from pandas import Series,DataFrame
3 import pandas as pd
/Users/...filepath.../Python/data_analysis/numpy.pyc in <module>()
17
18 import numpy as np
---> 19 from numpy.random import randn
20
21
ImportError: No module named random
我尝试将import random
添加到上面的代码中(在其他模块之前)并且它仍然会给出相同的错误。这可能是由于我系统上的gfortran版本?我有版本4.9.2
答案 0 :(得分:0)
由于我没有完整的代码,只是尝试使用import语句。
如果我们按@John使用<table>
<thead>
<tr>
<th>Name</th>
<th colspan="3">Actions</th>
</tr>
</thead>
<tbody>
<% @customers.each do |customer| %>
<tr>
<td><%= customer.name %></td>
<td><%= link_to 'Show', customer, remote: true %></td>
<td><%= link_to 'Edit', edit_customer_path(customer) %></td>
<td><%= link_to 'Destroy', customer, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
<%= link_to 'New Customer', new_customer_path, class: "button", id: "new_customer" %>
<div id="current_customer"> # This will will contain the partial
</div>
np
import numpy as np
我得到了
from np.random import randn
from np.random import randn
如果我从ImportError: No module named np.random
randn
,我没有收到任何错误
numpy.random
它为我工作,输出如下,
import numpy as np
from numpy.random import randn
print "randn1= ", randn()
from numpy.random import rand
print "rand1= ", rand()
您也可以尝试直接使用randn1= 0.147667079884
rand1= 0.243935746205
和np.random.randn()
。
np.random.rand()
我明白了:
import numpy as np
print "randn2= ", np.random.randn()
print "rand2= ", np.random.rand()
randn2= -0.22571513741