导入模块会导致属性错误

时间:2019-07-26 00:35:59

标签: python-3.x

在python脚本中,我尝试同时导入Bokeh和Seaborn,但是两次都收到错误消息。

这是使用anaconda完成的,另一个python脚本在另一个终端上运行。

import csv
import seaborn


x = []
y = []

with open('main.csv','r') as csvfile:
    plots = csv.reader(csvfile, delimiter=',')
    count = 1
    for row in plots:
        if count % 2 == 1:
            x.append(int(row[0]))
            y.append(int(row[1]))
        count += 1

seaborn.scatterplot(x, y)

导致出现以下错误消息:

  File "graphinganomalies.py", line 2, in <module>
    import seaborn as sns
  File "C:\Users\user\Anaconda3\lib\site-packages\seaborn\__init__.py", line 6, in <module>
    from .rcmod import *
  File "C:\Users\user\Anaconda3\lib\site-packages\seaborn\rcmod.py", line 5, in <module>
    from . import palettes, _orig_rc_params
  File "C:\Users\user\Anaconda3\lib\site-packages\seaborn\palettes.py", line 12, in <module>
    from .utils import desaturate, set_hls_values, get_color_cycle
  File "C:\Users\user\Anaconda3\lib\site-packages\seaborn\utils.py", line 7, in <module>
    from scipy import stats
  File "C:\Users\user\Anaconda3\lib\site-packages\scipy\stats\__init__.py", line 345, in <module>
    from .stats import *
  File "C:\Users\user\Anaconda3\lib\site-packages\scipy\stats\stats.py", line 171, in <module>
    from . import distributions
  File "C:\Users\user\Anaconda3\lib\site-packages\scipy\stats\distributions.py", line 10, in <module>
    from ._distn_infrastructure import (entropy, rv_discrete, rv_continuous,
  File "C:\Users\user\Anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py", line 16, in <module>
    from scipy.misc import doccer
  File "C:\Users\user\Anaconda3\lib\site-packages\scipy\misc\__init__.py", line 68, in <module>
    from scipy.interpolate._pade import pade as _pade
    from .interpolate import *
  File "C:\Users\user\Anaconda3\lib\site-packages\scipy\interpolate\interpolate.py", line 32, in <module>
    from .interpnd import _ndim_coords_from_arrays
  File "interpnd.pyx", line 1, in init scipy.interpolate.interpnd
  File "C:\Users\user\Anaconda3\lib\site-packages\scipy\spatial\__init__.py", line 95, in <module>
    from .ckdtree import *
  File "ckdtree.pyx", line 22, in init scipy.spatial.ckdtree
  File "C:\Users\user\Desktop\Programs\multiprocessing.py", line 2, in <module>
    len(os.sched_getaffinity(0))
AttributeError: module 'os' has no attribute 'sched_getaffinity'

1 个答案:

答案 0 :(得分:0)

调度程序功能(包括sched_getaffinity())在Windows上不可用:

https://docs.python.org/3/library/os.html#interface-to-the-scheduler

  

这些函数控制操作系统如何为进程分配CPU时间。 仅在某些Unix平台上可用。有关更多详细信息,请查阅Unix联机帮助页。