gpt4 book ai didi

python - 程序类卡住/空闲,并且在 Anaconda/命令行提示符中第一次调用后不执行剩余调用,但在 Spyder 中工作

转载 作者:太空宇宙 更新时间:2023-11-03 21:08:51 33 4
gpt4 key购买 nike

我正在尝试使用 anaconda 提示符来运行我的 python 脚本。它在第一次调用时运行顺利,但在那里就停止了。我尝试了 Spyder,它可以工作,但我希望它可以在 anaconda 提示符或命令行上工作。有什么原因吗?

from decompress import decompress
from reddit import reddit
from clean import clean
from wikipedia import wikipedia

def main():
dir_of_file = r"D:\Users\Jonathan\Desktop\Reddit Data\Demo\\"
print('0. Path: ' + dir_of_file)
reddit_repo = reddit()
wikipedia_repo = wikipedia()
pattern_filter = "*2007*&*2008*"
print('1. Creating data lake')
reddit_repo.download_files(pattern_filter,"https://files.pushshift.io/reddit/submissions/",dir_of_file,'s')
reddit_repo.download_files(pattern_filter,"https://files.pushshift.io/reddit/comments/",dir_of_file,'c')

if __name__ == "__main__":
main()

下载的 RS 是正在运行的这行代码:

reddit_repo.download_files(pattern_filter,"https://files.pushshift.io/reddit/submissions/",dir_of_file,'s') 

enter image description here更新:

添加了类/函数

class reddit:

def multithread_download_files_func(self,list_of_file):
filename = list_of_file[list_of_file.rfind("/")+1:]
path_to_save_filename = self.ptsf_download_files + filename
if not os.path.exists(path_to_save_filename):
data_content = None
try:
request = urllib.request.Request(list_of_file)
response = urllib.request.urlopen(request)
data_content = response.read()
except urllib.error.HTTPError:
print('HTTP Error')
except Exception as e:
print(e)
if data_content:
with open(path_to_save_filename, 'wb') as wf:
wf.write(data_content)
print(self.present_download_files + filename)

def download_files(self,filter_files_df,url_to_download_df,path_to_save_file_df,prefix):
#do some processing
matching_fnmatch_list.sort()

p = ThreadPool(200)
p.map(self.multithread_download_files_func, matching_fnmatch_list)

最佳答案

下载花了很多时间。我已经更改了网络并且它按预期工作。所以cmd或者anaconda提示符都没有问题

关于python - 程序类卡住/空闲,并且在 Anaconda/命令行提示符中第一次调用后不执行剩余调用,但在 Spyder 中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55200929/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com