설치 가이드: Python, PyCharm, Selenium 및 웹 드라이버
이 가이드는 Python, PyCharm 및 Selenium의 설치 프로세스를 단순화하기 위한 것입니다. 포괄적인 설치 지침을 검색할 때 많은 사람들이 직면하는 어려움을 완화하기 위해 이 초안을 만들었습니다. 연습용이든 업무용이든 다음 단계를 따르면 원활한 설정이 가능합니다.
1단계: Python 설치
윈도우
-
Python 다운로드:
- 파이썬 공식 홈페이지로 이동하세요.
- 최신 버전의 Python을 다운로드하세요.
-
설치 프로그램 실행:
- 다운로드한 설치 프로그램을 실행하세요.
- "PATH에 Python 추가" 확인란을 선택합니다.
- "지금 설치"를 클릭하세요.
- "MAX PATH LIMIT 비활성화(255)"를 클릭하세요.
macOS
-
Python 다운로드:
- 파이썬 공식 홈페이지로 이동하세요.
- 최신 버전의 Python을 다운로드하세요.
-
설치 프로그램 실행:
- 다운로드한 .pkg 파일을 엽니다.
- 설치 지침을 따르세요.
확신하는! macOS에서의 Python 설치 지침은 다음과 같습니다.
macOS에서의 Python 설치 지침
1단계: Python 다운로드
-
공식 Python 웹사이트로 이동:
- 웹 브라우저를 열고 공식 Python 웹사이트로 이동하세요.
-
최신 버전 다운로드:
- 웹사이트는 자동으로 운영 체제를 감지하고 macOS용 최신 버전을 제안해야 합니다.
- 설치 프로그램을 다운로드하려면 "Python [버전] 다운로드" 버튼을 클릭하세요.
2단계: Python 설치
-
설치 프로그램 실행:
- 다운로드가 완료되면 일반적으로 다운로드 폴더에서 다운로드한 파일을 찾으세요.
- .pkg 파일을 두 번 클릭하여 Python 설치 프로그램을 엽니다.
-
설치 단계를 따르세요:
- 설치 프로그램이 새 창을 엽니다. 설치 프로세스를 시작하려면 "계속"을 클릭하세요.
- 라이센스 계약을 검토하고 동의합니다.
- 설치 위치를 선택하세요. 기본 위치는 일반적으로 괜찮습니다.
- 설치를 시작하려면 "설치"를 클릭하세요.
- 설치를 승인하려면 macOS 비밀번호를 입력하라는 메시지가 나타날 수 있습니다. 비밀번호를 입력하고 "소프트웨어 설치"를 클릭하세요.
-
설치 완료:
- 설치가 완료되면 "닫기"를 클릭하여 설치 프로그램을 종료하세요.
3단계: 설치 확인
-
터미널 열기:
- 애플리케이션에서 터미널을 찾을 수 있습니다> 유틸리티 또는 Spotlight 검색 사용(Cmd + Space 및 "터미널" 입력).
-
Python 버전 확인:
- 터미널에 다음 명령을 입력하고 Enter를 누르세요.
python3 --version
-
pip 버전 확인:
- 터미널에 다음 명령을 입력하고 Enter를 누르세요.
pip3 --version
4단계: 환경 변수 설정(선택 사항)
-
PATH에 Python 추가:
- 터미널을 열고 다음 명령을 입력하여 텍스트 편집기에서 .bash_profile 또는 .zshrc 파일을 엽니다.
nano ~/.zshrc
또는
nano ~/.bash_profile
-
파일 편집:
export PATH="/Library/Frameworks/Python.framework/Versions/3.x/bin:$PATH"
- Ctrl + O를 눌러 파일을 저장한 다음 Enter를 누르세요. Ctrl + X를 눌러 종료하세요.
-
변경사항 적용:
- 터미널에서 다음 명령을 실행하여 변경 사항을 적용합니다.
source ~/.zshrc
또는
source ~/.bash_profile
5단계: Virtualenv 설치(선택 사항)
-
virtualenv 설치:
- 격리된 Python 환경을 만들려면 virtualenv를 사용할 수 있습니다. pip를 사용하여 설치합니다.
pip3 install virtualenv
-
가상 환경 만들기:
cd path/to/your/project
-
가상 환경 만들기:
virtualenv venv
-
가상 환경 활성화:
- Activate the virtual environment:
source venv/bin/activate
- You will see (venv) in your terminal prompt, indicating the virtual environment is active.
-
Deactivate the Virtual Environment:
- To deactivate the virtual environment, simply run:
deactivate
You have now installed Python on your macOS system, set up your environment variables, and optionally installed virtualenv for managing your projects.
Linux
-
Using APT (Debian/Ubuntu):
sudo apt update
sudo apt install python3 python3-pip
-
Using DNF (Fedora):
sudo dnf install python3 python3-pip
Step 2: Install PyCharm
-
Download PyCharm:
- Go to the JetBrains PyCharm website.
- Download the Community Edition (free) or Professional Edition (paid).
- Always remember to Check the System version and download compatible version else, you will able to install but not able open the pycharm software
-
Run the Installer:
- Follow the installation instructions provided by JetBrains.
- Certainly! Here are the installation instructions for PyCharm as provided by JetBrains:
Installation Instructions for PyCharm
Windows
-
Download PyCharm:
- Go to the JetBrains PyCharm download page.
- Download the Community Edition (free) or Professional Edition (paid).
-
Run the Installer:
- Double-click the downloaded .exe file to launch the installer.
- Follow the setup wizard:
- Click "Next" to continue.
- Choose the installation location and click "Next".
- Select the desired installation options:
- Create a desktop shortcut.
- Add the “bin” folder to the PATH (recommended).
- Associate .py files with PyCharm.
- Add an open folder as a project option.
- Click "Install".
- Once the installation is complete, click "Finish".
-
Launch PyCharm:
- After the installation, you can start PyCharm by double-clicking the PyCharm shortcut on your desktop or by searching for PyCharm in the Start menu.
macOS
-
Download PyCharm:
- Go to the JetBrains PyCharm download page.
- Download the Community Edition (free) or Professional Edition (paid).
-
Install PyCharm:
- Open the downloaded .dmg file.
- Drag and drop the PyCharm application into the Applications folder.
-
Launch PyCharm:
- Open Finder and go to the Applications folder.
- Find PyCharm and double-click to open it.
- If you see a warning about opening an application downloaded from the internet, click "Open".
Linux
-
Download PyCharm:
- Go to the JetBrains PyCharm download page.
- Download the tar.gz package for the Community Edition (free) or Professional Edition (paid).
-
Install PyCharm:
- Open your terminal.
- Navigate to the directory where the tar.gz file was downloaded.
- Extract the tar.gz file:
tar -xzf pycharm-*.tar.gz
-
Create a Desktop Entry (optional):
- While running PyCharm, go to the main menu and select "Tools" > "Create Desktop Entry".
First-time Startup
-
Activate PyCharm:
- On the first startup, you will be prompted to activate PyCharm.
- For the Community Edition, select "Evaluate for free" and click "Evaluate".
- For the Professional Edition, enter your JetBrains account credentials or use a license key.
-
Customize PyCharm:
- Choose your UI theme (Light or Dark).
- Configure additional settings as needed.
-
Create or Open a Project:
- You can now create a new project, open an existing project, or check out a project from version control.
For more detailed instructions and troubleshooting, refer to the official PyCharm installation guide.
Step 3: Install Selenium
-
Using pip:
- Open your command line or terminal, Run as Administrator
- Install Selenium using the following command:
pip install selenium
Step 4: Verify Installation
Check Python Installation:
python --version
Check pip Installation:
pip --version
Update pip Installation:
python -m pip install --upgrade pip
-
Verify if Selenium Installed Properly or Not:
pip show selenium
You should get the selenium details
Web Drivers:
For the latest Selenium Version: 4.22.0, Web Drivers have been pre installed
You can verify in path:
C:\Users\AppData\Local\Programs\Python\Python311\Lib\site-packages\selenium\webdriver
you will see the wedrivers for IE, Chrome, Edge, FireFox, Remote, Safari, Chromium.
Verify Selenium Installation:
Example: Basic Selenium Script
Here's a simple script to verify your Selenium setup. This script opens a web browser and navigates to a website.
-
Install WebDriver:
- Download the appropriate WebDriver for your browser (e.g., ChromeDriver for Chrome) from Selenium’s official site.
- Make sure to place the WebDriver executable in a directory that is in your PATH.
Create a Python Script:
from selenium import webdriver
# Initialize the WebDriver (assuming ChromeDriver is in your PATH)
driver = webdriver.Chrome()
# Open a website
driver.get("https://www.python.org")
# Print the title of the page
print(driver.title)
# Close the browser
driver.quit()
-
Run the Script:
- Save the script as test_selenium.py.
- Run the script in your command line or terminal:
python test_selenium.py
If everything is set up correctly, you should see the browser open, navigate to the Python website, and print the page title in the console.
Additional Selenium Web Drivers Configuration:
If you are using earlier versions or not able to see webdriver, you can download them or For more details you can see visit:
https://pypi.org/project/selenium/
After downloading the files, extract the files and copy the drivers.exe and place in the path or accordingly to your system files path
C:\Users\AppData\Local\Programs\Python\Python311\
This is a pre installed path for python that is available in the environment variables, which you pretty much can use without errors
or You can create a folder in "C drive" and add that file path in environment variables.
Driver "PATH" Configuration:
Here are the instructions on how to add the path C:\Users\AppData\Local\Programs\Python\Python311\ or any "PATH" to the environment variables in Windows:
Adding Python Path to Environment Variables in Windows
Step 1: Open Environment Variables Settings
-
Open System Properties:
- Press Win + Pause/Break to open the System window.
- Alternatively, you can right-click on the This PC or Computer icon on your desktop or in File Explorer and select Properties.
-
Open Advanced System Settings:
- In the System window, click on Advanced system settings on the left-hand side.
-
Open Environment Variables:
- In the System Properties window, click on the Environment Variables... button near the bottom.
Step 2: Edit the PATH Variable
-
Locate the PATH Variable:
- In the Environment Variables window, you will see two sections: User variables and System variables.
- Scroll down in the System variables section and find the variable named Path. Select it and click on the Edit... button.
-
Add New Path:
- In the Edit Environment Variable window, you will see a list of paths. Click on the New button to add a new path.
- Enter the path C:\Users\AppData\Local\Programs\Python\Python311\ in the new entry.
-
Save Changes:
- After adding the path, click OK to close the Edit Environment Variable window.
- Click OK again to close the Environment Variables window.
- Finally, click OK to close the System Properties window.
Step 3: Verify the Path Addition
-
Open Command Prompt:
- Press Win + R, type cmd, and press Enter to open the Command Prompt.
-
Check Python Version:
- Type the following command and press Enter:
python --version
- You should see the version of Python installed in
C:\Users\AppData\Local\Programs\Python\Python311\
If everything is set up correctly, the command prompt should display the Python version, confirming that the path has been successfully added to the environment variables.
These steps ensure that Python can be accessed from any command prompt window without needing to specify the full path to the executable each time.
위 내용은 Python, Pycharm, Selenium 및 웹 드라이버 설치의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!