Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Kill Ugly Radio -- Frank Zappa


devel / comp.lang.python / Re: Python-pickle error

SubjectAuthor
o Re: Python-pickle errorTony Flury

1
Re: Python-pickle error

<mailman.38.1683645161.13552.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=27593&group=comp.lang.python#27593

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: tony.flury@btinternet.com (Tony Flury)
Newsgroups: comp.lang.python
Subject: Re: Python-pickle error
Date: Tue, 9 May 2023 07:45:34 +0100
Lines: 73
Message-ID: <mailman.38.1683645161.13552.python-list@python.org>
References: <PAWPR03MB994760978DE511870B829299A9629@PAWPR03MB9947.eurprd03.prod.outlook.com>
<2b885cb4-8917-143b-b543-382133514d3f@btinternet.com>
Reply-To: tony.flury@btinternet.com
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de bqFPma1CbKxp3Ld0fwG6Kg/B0OwR2rXpzamfaf9HU1eg==
Return-Path: <tony.flury@btinternet.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=btinternet.com header.i=@btinternet.com header.b=g+QKgOdL;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.053
X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'traceback': 0.04; '(most':
0.05; 'last):': 0.05; 'string': 0.07; 'subject:error': 0.07;
'subject:Python': 0.12; 'import': 0.15; 'pickle': 0.16;
'unpickled': 0.16; 'wrote:': 0.16; 'problem': 0.16; 'python':
0.16; 'to:addr:python-list': 0.20; 'creates': 0.22; 'first,':
0.22; 'version': 0.23; 'code': 0.23; 'to:name:python-
list@python.org': 0.24; 'binary': 0.26; 'this?': 0.29; 'error':
0.29; 'header:User-Agent:1': 0.30; 'whole': 0.30; "doesn't": 0.32;
'deleted': 0.32; 'received:192.168.1': 0.32; 'but': 0.32;
'script': 0.33; "didn't": 0.34; 'header:In-Reply-To:1': 0.34;
'files': 0.36; 'fix': 0.36; 'really': 0.37; 'received:192.168':
0.37; 'though': 0.37; 'file': 0.38; 'could': 0.38; 'this,': 0.39;
'file:': 0.40; 'received:213': 0.40; 'hello,': 0.40; 'want': 0.40;
'skip:o 10': 0.61; 'format': 0.62; 'skip:o 20': 0.63; 'email':
0.63; 'your': 0.64; 'came': 0.65; 'before,': 0.69; 'del': 0.70;
'skip:f 20': 0.75; 'reply-to:no real name:2**0': 0.78; 'header
:Reply-To:1': 0.79; 'anthony': 0.84; 'skip:" 40': 0.84; 'skip:m
50': 0.84; 'spare': 0.84; 'to:addr:outlook.com': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=btinternet.com;
s=btmx201904; t=1683614735;
bh=doszNtHhS4c9N0hapUDiZlvJHLjjyn7XVwyLiXAyaks=;
h=Message-ID:Date:MIME-Version:Reply-To:Subject:To:References:From:In-Reply-To;
b=g+QKgOdLNQuvNOdJ0s2lVSK+akqOwSiaWE2ZsV7howFyz6qXkECFevUH6F6flKys9bYlRmnE0ePbgC6pN6JJuv+gE8iDnCrDToSotYU2yJltpBRMOkA33NY3LSXJS40E/KMJneY5PQqK4RUrpXSA3WL4wJuMD4aV4YeiLSlK5KFy3YmbAxaCAWZnkI9Bo0gW/+kZTeg0IMufXQQiNKGgZJm/Gxcz6j1L2NYLrezEoLotlviaH3/9bS41DglV7SuoIMif6bTgJ6nvhzXcrfKt0FG4Iv3p9sFnb1GBdxuXkEOfGuReanvi4YA+ywGqu9c6fWVkVwHqGZRMToZ0/Qt20A==
Authentication-Results: btinternet.com;
auth=pass (PLAIN) smtp.auth=tony.flury@btinternet.com;
bimi=skipped
X-SNCR-Rigid: 64067E9B077F1061
X-Originating-IP: [31.50.133.105]
X-OWM-Source-IP: 31.50.133.105 (GB)
X-OWM-Env-Sender: tony.flury@btinternet.com
X-VadeSecure-score: verdict=clean score=0/300, class=clean
X-RazorGate-Vade: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefledgudduudcutefuodetggdotefrodftvfcurfhrohhfihhlvgemuceutffkvffkuffjvffgnffgvefqofdpqfgfvfenuceurghilhhouhhtmecufedtudenucenucfjughrpefkffggfghruffvfhfhjggtgfesthekredttdefjeenucfhrhhomhepvfhonhihucfhlhhurhihuceothhonhihrdhflhhurhihsegsthhinhhtvghrnhgvthdrtghomheqnecuggftrfgrthhtvghrnhepgeekueeliedvuedugffggfelffetvdelkeekkefghfeileeuhedujeeutedttdeknecukfhppeefuddrhedtrddufeefrddutdehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehhvghloheplgduledvrdduieekrddurddvngdpihhnvghtpeefuddrhedtrddufeefrddutdehpdhmrghilhhfrhhomhepthhonhihrdhflhhurhihsegsthhinhhtvghrnhgvthdrtghomhdpnhgspghrtghpthhtohepvddprhgtphhtthhopegsohgsuddrvdehtddvuddusehouhhtlhhoohhkrdgtohhmpdhrtghpthhtohepphihthhhohhnqdhlihhsthesphihthhhohhnrdhorhhgpdhrvghvkffrpehhohhsthefuddqhedtqddufeefqddutdehrdhrrghnghgvfeduqdehtddrsghttggvnhhtrhgrlhhplhhushdrtghomhdprghuthhhpghushgvrhepthhonhihrdhflhhurhihsegsthhinhhtvghrnhgvthdrtghomhdpghgvohfkrfepifeupdfovfetjfhoshhtpehs
rgdqphhrugdqrhhgohhuthdqtddtvd
X-RazorGate-Vade-Verdict: clean 0
X-RazorGate-Vade-Classification: clean
X-SNCR-hdrdom: btinternet.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.10.0
Content-Language: en-US
In-Reply-To: <PAWPR03MB994760978DE511870B829299A9629@PAWPR03MB9947.eurprd03.prod.outlook.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <2b885cb4-8917-143b-b543-382133514d3f@btinternet.com>
X-Mailman-Original-References: <PAWPR03MB994760978DE511870B829299A9629@PAWPR03MB9947.eurprd03.prod.outlook.com>
 by: Tony Flury - Tue, 9 May 2023 06:45 UTC

Charles,

by your own admission, you deleted your pkl file,

And your code doesn't write that pkl file (pickle.dumps(...) doesn't
write a file it creates a new string and at no point will it write to
the file :

What you need is this :

import pickle
number=2
my_pickled_object=pickle.dumps(number)
with open('file.pkl', 'w') as file:
file.write(my_pickled_object)
print("this is my pickled object",{my_pickled_object},)

del number # you can do this if you really want to test pickle.

with open('file.pkl', 'r') as file:
number=pickle.load(file)

my_unpickled_object=pickle.loads(my_pickled_object)
print("this is my unpickled object",{my_unpickled_object},)

Note :  that the whole point of the pickle format is that you don't need
to open and write/read files in binary format.

On 19/04/2023 17:14, charles wiewiora wrote:
> Hello,
> I am experincing problems with the pickle moducle
> the folowing code was working before,
>
> import pickle
> number=2
> my_pickeld_object=pickle.dumps(number)
> print("this is my pickled object",{my_pickeld_object},)
> with open('file.pkl', 'rb') as file:
> number=pickle.load(file)
> my_unpickeled_object=pickle.loads(my_pickeld_object)
> print("this is my unpickeled object",{my_unpickeled_object},)
>
> but now i get error
>
> Traceback (most recent call last):
> File "C:\Users\lukwi\Desktop\python\tester2.py", line 5, in <module>
> with open('file.pkl', 'rb') as file:
> FileNotFoundError: [Errno 2] No such file or directory: 'file.pkl'
>
> im get this problem after this,
> a .pkl came into my Python script files
> i though this could be a spare file made from python becauce i was doing this first,
>
> import pickle
> number=2
> my_pickeld_object=pickle.dumps(number)
> print("this is my pickled object",{my_pickeld_object},)
> with open('file.pkl', 'rb') as file:
> number=pickle.load(file)
>
> so i stupidly deleted the file
>
> do you know how to fix this?
> i reinstalled it but it didn't work
> this is on widnows and on version 3.11.3 on python
>
> thank you

--
Anthony Flury
email : anthony.flury@btinternet.com


devel / comp.lang.python / Re: Python-pickle error

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor