To switch back to Python 2 on your Mac, you can follow these steps:
-
Uninstall Anaconda: Since you’ve already deleted the Anaconda folder, you may want to check if there are any remaining traces of Anaconda or Python 3 and remove them. You can do this by checking your
~/.bash_profile
,~/.bashrc
, and~/.profile
files for any Anaconda-related paths and removing them.مقالات ذات صلة -
Install Python 2:
- Download the latest version of Python 2 for macOS from the official Python website.
- Open the downloaded
.dmg
file and run the installer. - During the installation, make sure to select the option to install the command-line tools.
-
Update Your Shell Profile:
- Open a terminal window.
- Edit your shell profile (
.bash_profile
,.bashrc
, or.zshrc
depending on your setup) using a text editor likenano
orvim
:bashnano ~/.bash_profile
- Add the following line at the end of the file to ensure that Python 2 is used as the default Python interpreter:
bash
export PATH="/usr/local/bin:$PATH"
-
Apply Changes:
- Save the file and exit the text editor (
Ctrl + X
, thenY
to confirm, thenEnter
). - Source the updated shell profile to apply the changes:
bash
source ~/.bash_profile
- Save the file and exit the text editor (
-
Verify Installation:
- Check if Python 2 is now the default Python interpreter by running:
bash
python --version
- You should see the version of Python 2 you installed.
- Check if Python 2 is now the default Python interpreter by running:
After following these steps, you should have Python 2 set up as your default Python interpreter on your Mac.
المزيد من المعلومات
بالتأكيد! إذا كنت تواجه مشكلة في تنزيل Python 2 من موقع Python الرسمي، يمكنك استخدام Homebrew لتثبيت Python 2 بسهولة. يمكنك اتباع الخطوات التالية:
-
تثبيت Homebrew:
- افتح محرر النصوص (مثل Terminal) وقم بتشغيل الأمر التالي:
bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
- اتبع التعليمات على الشاشة لإكمال التثبيت.
- افتح محرر النصوص (مثل Terminal) وقم بتشغيل الأمر التالي:
-
تثبيت Python 2 باستخدام Homebrew:
- بمجرد تثبيت Homebrew، قم بتنفيذ الأمر التالي لتثبيت Python 2:
bash
brew install python@2
- ستحتاج إلى تأكيد التثبيت بإدخال كلمة المرور الخاصة بك.
- بمجرد تثبيت Homebrew، قم بتنفيذ الأمر التالي لتثبيت Python 2:
-
تحديث ملفات النظام:
- يجب عليك تحديث ملفات النظام لاستخدام Python 2 كافتراضي. قم بتحرير ملف
.bash_profile
باستخدام الأمر التالي:bashnano ~/.bash_profile
- أضف السطر التالي في نهاية الملف:
bash
export PATH="/usr/local/opt/python@2/libexec/bin:$PATH"
- احفظ التغييرات وأغلق المحرر (
Ctrl + X
ثمY
ثمEnter
).
- يجب عليك تحديث ملفات النظام لاستخدام Python 2 كافتراضي. قم بتحرير ملف
-
تطبيق التغييرات:
- قم بتنفيذ الأمر التالي لتطبيق التغييرات:
bash
source ~/.bash_profile
- قم بتنفيذ الأمر التالي لتطبيق التغييرات:
-
التحقق من التثبيت:
- قم بالتحقق من أن Python 2 قد تم تثبيته بنجاح بواسطة الأمر:
bash
python2 --version
- يجب أن تظهر إصدار Python 2 الذي قمت بتثبيته.
- قم بالتحقق من أن Python 2 قد تم تثبيته بنجاح بواسطة الأمر:
بعد اتباع هذه الخطوات، يجب أن يكون لديك Python 2 مثبتًا ومضبوطًا كافتراضي على نظام macOS الخاص بك.