Уведомления

Группа в Telegram: @pythonsu

#1 Май 9, 2023 14:21:12

Etaie
Зарегистрирован: 2023-05-09
Сообщения: 1
Репутация: +  0  -
Профиль   Отправить e-mail  

При попытке изобразить граф с помощью nx.draw(g) и plt.show() выдаёт кучу ошибок

Вот сам код:
import matplotlib.pyplot as plt
import networkx as nx

G = nx.Graph()
nodes =
edges =
G.add_nodes_from(nodes)
G.add_edges_from(edges)
nx.draw(G, with_labels=True, font_weight='bold')
plt.show()

А вот ошибки, которые он мне выдаёт
error reading package index file CUsers/chesn/AppData/Local/Programs/Python/Python311/tcl/tk8.6/pkgIndex.tcl: invalid command name “ ”
Traceback (most recent call last):
File “C:\Users\chesn\PycharmProjects\pythonProject\main.py”, line 9, in <module>
nx.draw(G, with_labels=True, font_weight='bold')
File “C:\Users\chesn\PycharmProjects\pythonProject\venv\Lib\site-packages\networkx\drawing\nx_pylab.py”, line 108, in draw
cf = plt.gcf()
^^^^^^^^^
File “C:\Users\chesn\PycharmProjects\pythonProject\venv\Lib\site-packages\matplotlib\pyplot.py”, line 906, in gcf
return figure()
^^^^^^^^
File “C:\Users\chesn\PycharmProjects\pythonProject\venv\Lib\site-packages\matplotlib\_api\deprecation.py”, line 454, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\chesn\PycharmProjects\pythonProject\venv\Lib\site-packages\matplotlib\pyplot.py”, line 840, in figure
manager = new_figure_manager(
^^^^^^^^^^^^^^^^^^^
File “C:\Users\chesn\PycharmProjects\pythonProject\venv\Lib\site-packages\matplotlib\pyplot.py”, line 384, in new_figure_manager
return _get_backend_mod().new_figure_manager(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\chesn\PycharmProjects\pythonProject\venv\Lib\site-packages\matplotlib\backend_bases.py”, line 3574, in new_figure_manager
return cls.new_figure_manager_given_figure(num, fig)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\chesn\PycharmProjects\pythonProject\venv\Lib\site-packages\matplotlib\backend_bases.py”, line 3579, in new_figure_manager_given_figure
return cls.FigureCanvas.new_manager(figure, num)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\chesn\PycharmProjects\pythonProject\venv\Lib\site-packages\matplotlib\backend_bases.py”, line 1742, in new_manager
return cls.manager_class.create_with_canvas(cls, figure, num)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\chesn\PycharmProjects\pythonProject\venv\Lib\site-packages\matplotlib\backends\_backend_tk.py”, line 483, in create_with_canvas
window = tk.Tk(className=“matplotlib”)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\chesn\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py”, line 2326, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: Can't find a usable tk.tcl in the following directories:
CUsers/chesn/AppData/Local/Programs/Python/Python311/tcl/tcl8.6/tk8.6 CUsers/chesn/AppData/Local/Programs/Python/Python311/tcl/tk8.6 CUsers/chesn/AppData/Local/Programs/Python/lib/tk8.6 CUsers/chesn/AppData/Local/Programs/Python/lib/tk8.6 CUsers/chesn/AppData/Local/Programs/lib/tk8.6 CUsers/chesn/AppData/Local/Programs/Python/library

CUsers/chesn/AppData/Local/Programs/Python/Python311/tcl/tk8.6/tk.tcl: invalid command name “ ”
invalid command name “ ”
while executing
“ …”
(file “CUsers/chesn/AppData/Local/Programs/Python/Python311/tcl/tk8.6/msgs/ru.msg” line 1)
invoked from within
“::source -encoding utf-8 CUsers/chesn/AppData/Local/Programs/Python/Python311/tcl/tk8.6/msgs/ru.msg”
(in namespace inscope “::tk::msgcat” script line 1)
invoked from within
"namespace inscope $ns


  • (procedure ”Load“ line 34)
    invoked from within
    ”Load $ns “
    (procedure ”::msgcat::mcpackageconfig“ line 46)
    invoked from within
    ”::msgcat::mcpackageconfig set mcfolder CUsers/chesn/AppData/Local/Programs/Python/Python311/tcl/tk8.6/msgs“
    (”uplevel“ body line 1)
    invoked from within
    ”uplevel 1 [list set mcfolder $langdir]“
    (procedure ”::msgcat::mcload“ line 2)
    invoked from within
    ”::msgcat::mcload “
    (in namespace eval ”::tk::msgcat“ script line 23)
    invoked from within
    ”namespace eval msgcat {
    namespace export mc mcmax
    if { || } {
    # The msgcat package…“
    (in namespace eval ”::tk“ script line 3)
    invoked from within
    ”namespace eval ::tk {
    # Set up the msgcat commands
    namespace eval msgcat {
    namespace export mc mcmax
    if { || [catch {p…“
    (file ”CUsers/chesn/AppData/Local/Programs/Python/Python311/tcl/tk8.6/tk.tcl“ line 17)
    invoked from within
    ”source CUsers/chesn/AppData/Local/Programs/Python/Python311/tcl/tk8.6/tk.tcl“
    (”uplevel“ body line 1)
    invoked from within
    ”uplevel #0 "


    This probably means that tk wasn't installed properly.

Офлайн

Board footer

Модераторировать

Powered by DjangoBB

Lo-Fi Version