> ## Documentation Index
> Fetch the complete documentation index at: https://ayakaleaf-pro.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Python Runner

> شغّل سكربت Python في مشروعك واحفظ ما يكتبه، مثل الأشكال الخاصة بمستندك.

تعمل سكربتات Python في متصفحك، لذا يظهر الناتج مباشرة أسفل المحرر. لا حاجة إلى أي إعداد.

**1. أنشئ سكربتًا**

في شجرة الملفات، انقر على أيقونة **New file**. أدخل اسمًا ينتهي بـ `.py` وانقر على **Create**.

![مربع الحوار Add Files بالاسم analysis.py](https://mintcdn.com/ayakaleaf-pro/PeD9iteXIf8j4GXw/images/on-premises/python-runner-new-file.png?fit=max\&auto=format\&n=PeD9iteXIf8j4GXw\&q=85\&s=6be49974e488f7678604cc0644f43bdc)

ملف Python جديد

يظهر الزر **Run** ولوحة الناتج أسفل المحرر. في المرة الأولى يبقى الزر معطّلًا أثناء تحميل Python.

**2. شغّله**

اكتب الشيفرة وانقر على **Run**. يظهر ما يطبعه السكربت في لوحة الناتج. لا تحتاج إلى الحفظ أولًا.

تُحفظ الملفات التي يكتبها السكربت في مشروعك. تخبرك رسالة بأسمائها، مثل **results.txt saved to your project**، ويظهر الملف في شجرة الملفات.

![سكربت في المحرر، وناتجه المطبوع أسفله، والرسالة results.txt saved to your project](https://mintcdn.com/ayakaleaf-pro/PeD9iteXIf8j4GXw/images/on-premises/python-runner-output.png?fit=max\&auto=format\&n=PeD9iteXIf8j4GXw\&q=85\&s=28188ffe214aedd1203d2734891917f7)

الناتج وملف محفوظ

**3. أوقف السكربت**

أثناء تشغيل السكربت يتحوّل **Run** إلى **Stop**. انقر عليه لمقاطعة السكربت. تنتهي لوحة الناتج بـ **Execution interrupted**.

![الزر Stop وناتج سكربت قيد التشغيل](https://mintcdn.com/ayakaleaf-pro/PeD9iteXIf8j4GXw/images/on-premises/python-runner-stop.png?fit=max\&auto=format\&n=PeD9iteXIf8j4GXw\&q=85\&s=263af195efa53538f1e3b37b4fad6041)

سكربت قيد التشغيل

## استخدام شكل في مستندك

لا توجد نافذة تظهر فيها الرسوم البيانية، لذا احفظها في ملف. على سبيل المثال:

```python theme={null}
import matplotlib.pyplot as plt

plt.plot([1, 2, 3], [1, 4, 9])
plt.savefig("figure.png")
```

يظهر `figure.png` في مشروعك، جاهزًا لـ `\includegraphics{figure.png}`.

![الملف figure.png مفتوحًا في المحرر، مع الرسالة figure.png saved to your project](https://mintcdn.com/ayakaleaf-pro/PeD9iteXIf8j4GXw/images/on-premises/python-runner-figure.png?fit=max\&auto=format\&n=PeD9iteXIf8j4GXw\&q=85\&s=8b0074f8d46a40a105a459a6c09caabf)

رسم بياني محفوظ

## قراءة ملفات مشروعك

يمكن للسكربت فتح ملفات مشروعك عبر مساراتها:

```python theme={null}
print(open("results.txt").read())
```

## إذا حدث خطأ

**السكربت يطلق خطأً.** يظهر الخطأ باللون الأحمر في لوحة الناتج، بعد كل ما طبعه السكربت قبله.

![نص مطبوع يليه traceback باللون الأحمر](https://mintcdn.com/ayakaleaf-pro/PeD9iteXIf8j4GXw/images/on-premises/python-runner-error.png?fit=max\&auto=format\&n=PeD9iteXIf8j4GXw\&q=85\&s=89ef60d790737fe01d6d69b1e0395e9e)

خطأ في سكربت

**`ModuleNotFoundError: No module named ...`.** لا تتوفر إلا الحزم المضمّنة في Pyodide، ولا يمكن استخدام الحزم المثبّتة بـ `pip`. تُعد NumPy وMatplotlib من الحزم المتاحة، وتحتوي الرسالة على رابط إلى [القائمة الكاملة](https://pyodide.org/en/stable/usage/packages-in-pyodide.html).

![خطأ ModuleNotFoundError في لوحة الناتج](https://mintcdn.com/ayakaleaf-pro/PeD9iteXIf8j4GXw/images/on-premises/python-runner-missing-package.png?fit=max\&auto=format\&n=PeD9iteXIf8j4GXw\&q=85\&s=5dbbfca95ee2b6984e2b3220e500231a)

حزمة غير متاحة


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.