Python Forum
problem with memory_graph module
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem with memory_graph module
#1
hi
code:
# from:https://pypi.org/project/memory-graph/
'''
custom copy method
We can write our own custom copy function or method in case the
three "copy" options don't do what we want. For example the
copy() method of My_Class in the code below copies the numbers
but shares the letters between the two objects.
'''

import memory_graph
import copy
import os

class My_Class:

    def __init__(self):
        self.numbers = [1, 2]
        self.letters = ['a', 'b']

    def copy(self): # custom copy method copies the numbers but shares the letters
        c = copy.copy(self)
        c.numbers = copy.copy(self.numbers)
        return c

a = My_Class()
b = a.copy()
print(a.numbers,b.numbers)
print(a.letters,b.letters)
a.numbers=[100,100]
print(a.numbers,b.numbers)
print(a.letters,b.letters)
a.letters[0]='a_changed'
print(a.numbers,b.numbers)
print(a.letters,b.letters)

myfile="memory_graph.gv.pdf"
if os.path.isfile(myfile):
    os.remove(myfile)
memory_graph.show(locals())
first, consider the above code and comment on the if condition and its block.
the code is run truly and creates a file as "memory_graph.gv.pdf"
if I run again the code, because of the presence above file in the same directory, errors appear. because the number of error lines is larger than 30, so I do not include it here.
I want to delete the mentioned file before the memory_graph.show(locals()) line is run, so I write the if block to delete the file. but the below error appears:
Error:
Traceback (most recent call last): File "D:\akb_python\akb_py_projects\memory_graph\custom_copy.py", line 38, in <module> os.remove(myfile) PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'memory_g raph.gv.pdf'
what can I do to correct the code?
thanks
Reply
#2
Maybe you can't. Does this only happen when you try to do view two memory graphs at the same time? If so, my guess is the viewer left memory_graph.gv.pdf open.

I tried running your program, but memory-graph doesn't run on my windows computer with python 3.11.
Reply
#3
(Mar-03-2024, 03:44 PM)deanhystad Wrote: Maybe you can't. Does this only happen when you try to do view two memory graphs at the same time? If so, my guess is the viewer left memory_graph.gv.pdf open.

I tried running your program, but memory-graph doesn't run on my windows computer with python 3.11.

hi
thanks for reply
according tohttps://pypi.org/project/memory-graph/ I installed memory_graph with pip and also a small app with the name graphviz must be installed.I have python 3.11.5 in my pc(win 10).
Reply
#4
It works fine for me when i test most run 2 times for it two overwrite memory_graph.gv.pdf.
If i want to save a graph just rename to eg factorial_grah.pdf.
Then when run again a new graph will be again in the default memory_graph.gv.pdf.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  problem using coloeama module akbarza 3 586 Jan-08-2024, 07:31 AM
Last Post: akbarza
  problem in using subprocess module akbarza 5 1,045 Sep-24-2023, 02:02 PM
Last Post: snippsat
  problem in import module from other folder akbarza 5 1,445 Sep-01-2023, 07:48 AM
Last Post: Gribouillis
  problem in using pyqrcode module to create QRcode akbarza 9 2,006 Aug-23-2023, 04:17 PM
Last Post: snippsat
  Problem with Pyinstaller. No module named '_tkinter' tonynapoli2309 0 1,021 May-15-2023, 02:38 PM
Last Post: tonynapoli2309
  Problem with module time and leap seconds Pedroski55 3 1,259 Oct-07-2022, 11:27 PM
Last Post: Pedroski55
  keyboard module; must be root problem philipbergwerf 2 19,130 Apr-04-2021, 11:40 AM
Last Post: philipbergwerf
  Problem with Flask Bcrypt import module marcello86 2 5,748 Aug-31-2020, 08:10 PM
Last Post: marcello86
  Js2Py module not found problem Charliedactyl1 5 7,946 Jun-14-2020, 07:39 PM
Last Post: buran
  Python 36-32 problem encoding module not found mkgrtn 0 2,448 Apr-14-2020, 09:57 PM
Last Post: mkgrtn

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020