无法在 python 3.6 中安装 pickle

新手上路,请多包涵

我正在尝试运行以下代码:

 import bs4 as bs
import pickle
import requests
import lxml

def save_sp500_tickers():
    resp = requests.get("https://en.wikipedia.org/wiki/List_of_S%26P_500_companies")
    soup = bs.BeautifulSoup(resp.text, "html5lib")
    table = soup.find("table", { "class" : "wikitable sortable"})
    # print(soup)
    # print(soup.table)

    tickers = []
    for row in table.findAll("tr")[1:]:
        ticker = row.findAll("td")[0].text
        tickers.append(ticker)
    with open("sp500tickers.pickle","wb") as f:
        pickle.dump(tickers, f)
    print(tickers)
#   return tickers
# save_sp500_tickers()

它不会抛出任何错误,但我意识到未安装 pickle 模块。我尝试通过 pip 安装它并收到以下错误:-

 D:\py_fin>pip install pickle
Collecting pickle
  Could not find a version that satisfies the requirement pickle (from versions:
 )
No matching distribution found for pickle

我们如何在 python 3.6(32 位)中安装 pickle?

原文由 satyaki 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 883
1 个回答

pickle 模块 很长一段时间以来都是 Python 标准库的一部分,因此无需通过 pip 安装它。我想知道您的 IDE 或命令行是否以某种方式搞砸了,以至于找不到 python 安装路径。请检查您的 %PATH% 是否包含 python 的路径(例如 C:\Python36\ 或类似的东西)或者您的 IDE 是否正确检测到安装 Python 的根路径。

原文由 sophros 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题