作者:LISA_W186 | 来源:互联网 | 2023-10-12 11:37
我想使用Anaconda Python环境。但是当我执行任何操作时,Anaconda和Miniconda都会崩溃。我同时使用了Wing和Pycharm-结果相同。文件的作用似乎无关紧要,但这是使文件崩溃的类型:
import numpy as np
import random
import datetime
import matplotlib
matplotlib.use('TkAgg')
from matplotlib import pyplot as plt
from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()
numDays = 30
def time_series_generator(series_type,vectorSize=500,show_series_plot=False):
if series_type == "RW":
RW = np.zeros(vectorSize)
RW[0] = np.exp(random.normalvariate(mu=0,sigma=10))
for index in range(1,vectorSize):
RW[index] = RW[index - 1] + random.normalvariate(mu=0,sigma=1)
return RW
def synthetic_data_generator(numDays):
# Randomly generated data
data = list(time_series_generator(series_type="RW",vectorSize=numDays,show_series_plot=False))
# generate randomized periodic dataArray from data
data1 = []
data2 = []
data3 = []
for index in range(0,len(data),1):
data1.append(data[index] + 0.1*np.random.normal(0,1))
data2.append(data[index] + 0.1*np.random.normal(0,1))
data3.append(data[index] + 0.1*np.random.normal(0,1))
dataArray = np.abs((data1 + data2) + data3)
# Scale to [0,100]
if np.max(dataArray) > 100:
C_t = random.randint(0,100) * dataArray / np.max(dataArray)
else:
C_t = dataArray
data = list(time_series_generator(series_type="RW",show_series_plot=False))
data1 = []
data2 = []
data3 = []
for index in range(0,1))
dataArray = np.abs((data1 + data2) + data3)
if np.max(dataArray) > 100:
M_t = random.randint(0,100) * dataArray / np.max(dataArray)
else:
M_t = dataArray
# More realistic F_t
data = list(time_series_generator(series_type="RW",vectorSize=3*numDays,show_series_plot=False))
F_t = []
for index in range(0,1):
F_t.append(np.abs(random.randint(0,100)*data[index]/np.max(np.abs(data))))
base = datetime.datetime.today()
T = [base + datetime.timedelta(days=x) for x in range(3 * numDays)]
return C_t,M_t,F_t,T
if __name__ == "__main__":
C_t,T = synthetic_data_generator(numDays)
line1 = plt.plot(T,C_t,color='blue')
line2 = plt.plot(T,color='green')
line3 = plt.plot(T,color='red')
plt.legend(('C(t)','M(t)','F(t)'))
plt.show()
我在threadDump日志中看不到任何有用的东西。
关于如何弄清楚发生了什么的任何想法?其他哪些信息可能会有帮助?
谢谢!
问题似乎是matplotlib希望解释器成为框架。
运行此;
conda install python.app
和pythonw将被安装。然后选择/ opt / anaconda3 / bin / pythonw作为项目解释器。它似乎有效。 Mac可能是愚蠢的机器。