dataabc / weiboSpider

新浪微博爬虫,用python爬取新浪微博数据
8.37k stars 1.98k forks source link

运行spider.py的时候报错 #177

Closed sunxiao06 closed 4 years ago

sunxiao06 commented 4 years ago

就是我运行spider.py代码后,报ImportError: attempted relative import with no known parent package,我网上查找了,但是却没有解惑,,所以想来问问

dataabc commented 4 years ago

感谢反馈。

不要直接运行spider.py,可以在weiboSpider目录下运行python3 -m weibo_spider,或者运行main.py

sunxiao06 commented 4 years ago

为啥它老是报cookie错误或者过期呢?

sunxiao06 commented 4 years ago

大大,我解决了,之前获取的cookie不对,现在可以了,麻烦了

arrogant-create commented 4 years ago

直接运行main还是报错,怎么办

dataabc commented 4 years ago

@arrogant-create

可以在weiboSpider目录下运行

$ python3 -m weibo_spider

或者在weiboSpider\weibo_spider目录下运行


$ python3 __main__.py
arrogant-create commented 4 years ago

还是什么都没有,具体操作是打开vscode,pip安装,再次执行python3 -m weibo_spider --config_path="config.json"没有任何反应了,无论执行什么也没生成weibo文件夹

dataabc commented 4 years ago

@arrogant-create

报什么错了吗?有使用者使用命令没有报错也没有执行,他本地是python3,使用

python -m weibo_spider

就能成功

arrogant-create commented 4 years ago

python3.8版本,用python -m weibo_spider命令出现以下错误: E:\pa\weiboSpider-master>python -m weibo_spider Error: [Errno 2] No such file or directory: 'E:\pa\weiboSpider-master\weibo_spider\config_sample.json' Traceback (most recent call last): File "E:\pa\weiboSpider-master\weibo_spider\spider.py", line 254, in main config = _get_config() File "E:\pa\weiboSpider-master\weibo_spider\spider.py", line 239, in _get_config shutil.copy(src, config_path) File "C:\Users\dell\AppData\Local\Programs\Python\Python38-32\lib\shutil.py", line 415, in copy copyfile(src, dst, follow_symlinks=follow_symlinks) File "C:\Users\dell\AppData\Local\Programs\Python\Python38-32\lib\shutil.py", line 261, in copyfile with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst: FileNotFoundError: [Errno 2] No such file or directory: 'E:\pa\weiboSpider-master\weibo_spider\config_sample.json'

dataabc commented 4 years ago

@arrogant-create

这个错误是因为你的'E:\pa\weiboSpider-master\weibo_spider\'下没有config_sample.json文件,是不是你把它重命名了,再改回来或者单独下载,再运行就可以了

arrogant-create commented 4 years ago

可以了,非常感谢,用python就可以运行,谢谢大大

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

Closing as stale, please reopen if you'd like to work on this further.