无法在 python 3.6 中 pip install pickle

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48477949/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 18:43:22  来源:igfitidea点击:

Not able to pip install pickle in python 3.6

pythonpickle

提问by satyaki

I am trying to run the below code:-

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

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()

it does not throws any error but i realized pickle module is not installed. I went to install it via pip and getting below error:-

它没有抛出任何错误,但我意识到没有安装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

I tried google'd about it but did not get a solution. Please help. How do we install pickle in python 3.6(32-bit)

我试过谷歌搜索,但没有得到解决方案。请帮忙。我们如何在python 3.6(32位)中安装pickle

回答by sophros

picklemoduleis part of the standard library in Python for a very long time now so there is no need to install it via pip. I wonder if you IDE or command line is not messed up somehow so that it does not find python installation path. Please check if your %PATH%contains a path to python (e.g. C:\Python36\or something similar) or if your IDE correctly detects root path where Python is installed.

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

回答by Amogh Jahagirdar

You can pip install pickle by running command pip install pickle-mixin. Proceed to import it using import pickle. This can be then used normally.

您可以通过运行命令 pip install pickle pip install pickle-mixin。继续使用导入它import pickle。然后就可以正常使用了。

回答by Simon

Pickle is a module installed for both Python 2 and Python 3 by default. See the standard library for 3.6.4and 2.7.

Pickle 是默认为 Python 2 和 Python 3 安装的模块。请参阅3.6.42.7的标准库。

Also to prove what I am saying is correct try running this script:

还要证明我所说的是正确的,请尝试运行此脚本:

import pickle
print(pickle.__doc__)

This will print out the Pickle documentation showing you all the functions (and a bit more) it provides.

这将打印出 Pickle 文档,向您展示它提供的所有功能(以及更多功能)。

Or you can start the integrated Python 3.6 Module Docs and check there.

或者您可以启动集成的 Python 3.6 模块文档并在那里检查。

As a rule of thumb: if you can import the module without an error being produced then it is installed

根据经验:如果您可以导入模块而不会产生错误,那么它就会被安装

The reason for the No matching distribution found for pickleis because libraries for included packages are not available via pip because you already have them (I found this out yesterday when I tried to install an integrated package).

原因No matching distribution found for pickle是因为包含包的库不能通过 pip 使用,因为你已经有了它们(我昨天在尝试安装集成包时发现了这一点)。

If it's running without errors but it doesn't work as expected I would think that you made a mistake somewhere (perhaps quickly check the functions you are using in the docs). Python is very informative with it's errors so we generally know if something is wrong.

如果它运行没有错误但没有按预期工作,我会认为您在某个地方犯了错误(也许快速检查您在文档中使用的功能)。Python 的错误信息非常丰富,因此我们通常知道是否有问题。

回答by Oleg Butuzov

import pickle

intArray = [i for i in range(1,100)]
output = open('data.pkl', 'wb')
pickle.dump(intArray, output)
output.close()

Test your pickle quickly. pickleis a part of standard python library and available by default.

快速测试你的泡菜。pickle是标准 python 库的一部分,默认情况下可用。

回答by SanthoshKumarBelman

I had a similar error & this is what I found.

我有一个类似的错误,这就是我发现的。

My environment details were as below:steps followed at my end

我的环境详细信息如下:我最后遵循的步骤

c:\>pip --version
pip 20.0.2 from c:\python37_64\lib\site-packages\pip (python 3.7)

C:\>python --version
Python 3.7.6

As per the documentation, apparently, python 3.7 already has the pickle package. So it does not require any additional download. I checked with the following command to make sure & it worked.

根据文档,显然,python 3.7 已经有了 pickle 包。所以它不需要任何额外的下载。我检查了以下命令以确保它有效。

C:\Python\Experiements>python
Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>>

So, pip install picklenot required for python v3.7 for sure

所以,pip install picklepython v3.7 肯定不需要