”工欲善其事,必先利其器。“—孔子《论语.录灵公》
首页 > 编程 > Python、Pycharm、Selenium 和 Web 驱动程序的安装

Python、Pycharm、Selenium 和 Web 驱动程序的安装

发布于2024-07-29
浏览:248

Installation of Python, Pycharm, Selenium and Web Drivers

Installation Guide: Python, PyCharm, Selenium and Web Drivers

This guide is intended to simplify the installation process for Python, PyCharm, and Selenium. I've created this draft to help ease the difficulty many people face when searching for comprehensive installation instructions. Whether for practice or work, following these steps will ensure a smooth setup experience.

Step 1: Install Python

Windows

  1. Download Python:

    • Go to the official Python website.
    • Download the latest version of Python.
  2. Run the Installer:

    • Run the downloaded installer.
    • Check the box "Add Python to PATH".
    • Click "Install Now".
    • Click on "Disable MAX PATH LIMIT(255)".

macOS

  1. Download Python:

    • Go to the official Python website.
    • Download the latest version of Python.
  2. Run the Installer:

    • Open the downloaded .pkg file.
    • Follow the installation instructions. Sure! Here are the installation instructions for Python on macOS:

Installation Instructions for Python on macOS

Step 1: Download Python

  1. Go to the Official Python Website:

    • Open your web browser and navigate to the official Python website.
  2. Download the Latest Version:

    • The website should automatically detect your operating system and suggest the latest version for macOS.
    • Click the "Download Python [version]" button to download the installer.

Step 2: Install Python

  1. Run the Installer:

    • Once the download is complete, locate the downloaded file, typically in your Downloads folder.
    • Double-click the .pkg file to open the Python installer.
  2. Follow the Installation Steps:

    • The installer will open a new window. Click "Continue" to begin the installation process.
    • Review and agree to the license agreement.
    • Choose the installation location. The default location is usually fine.
    • Click "Install" to start the installation.
    • You may be prompted to enter your macOS password to authorize the installation. Enter your password and click "Install Software".
  3. Complete the Installation:

    • Once the installation is complete, click "Close" to exit the installer.

Step 3: Verify the Installation

  1. Open Terminal:

    • You can find Terminal in Applications > Utilities or by using Spotlight Search (Cmd Space and type "Terminal").
  2. Check Python Version:

    • In Terminal, type the following command and press Enter:
     python3 --version
    
  • You should see the version of Python you installed. For example:

     Python 3.x.x
    
  1. Check pip Version:

    • In Terminal, type the following command and press Enter:
     pip3 --version
    
  • You should see the version of pip installed with Python. For example:

     pip 21.x.x from /Library/Frameworks/Python.framework/Versions/3.x/lib/python3.x/site-packages/pip (python 3.x)
    

Step 4: Set Up Environment Variables (Optional)

  1. Add Python to PATH:

    • Open Terminal and enter the following command to open the .bash_profile or .zshrc file in a text editor:
     nano ~/.zshrc
    

    or

     nano ~/.bash_profile
    
  2. Edit the File:

    • Add the following line to the file:
     export PATH="/Library/Frameworks/Python.framework/Versions/3.x/bin:$PATH"
    
  • Save the file by pressing Ctrl O, then press Enter. Exit by pressing Ctrl X.
  1. Apply Changes:

    • In Terminal, run the following command to apply the changes:
     source ~/.zshrc
    

    or

     source ~/.bash_profile
    

Step 5: Install Virtualenv (Optional)

  1. Install virtualenv:

    • To create isolated Python environments, you can use virtualenv. Install it using pip:
     pip3 install virtualenv
    
  2. Create a Virtual Environment:

    • Navigate to your project directory:
     cd path/to/your/project
    
  • Create a virtual environment:

     virtualenv venv
    
  1. Activate the Virtual Environment:

    • Activate the virtual environment:
     source venv/bin/activate
    
  • You will see (venv) in your terminal prompt, indicating the virtual environment is active.
  1. 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

  1. Using APT (Debian/Ubuntu):
   sudo apt update
   sudo apt install python3 python3-pip
  1. Using DNF (Fedora):
   sudo dnf install python3 python3-pip

Step 2: Install PyCharm

  1. 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
  2. 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

  1. Download PyCharm:

    • Go to the JetBrains PyCharm download page.
    • Download the Community Edition (free) or Professional Edition (paid).
  2. 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".
  3. 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

  1. Download PyCharm:

    • Go to the JetBrains PyCharm download page.
    • Download the Community Edition (free) or Professional Edition (paid).
  2. Install PyCharm:

    • Open the downloaded .dmg file.
    • Drag and drop the PyCharm application into the Applications folder.
  3. 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

  1. Download PyCharm:

    • Go to the JetBrains PyCharm download page.
    • Download the tar.gz package for the Community Edition (free) or Professional Edition (paid).
  2. 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
    
  • Move to the extracted directory:

     cd pycharm-*/
    
  • Run PyCharm:

     ./bin/pycharm.sh
    
  1. Create a Desktop Entry (optional):
    • While running PyCharm, go to the main menu and select "Tools" > "Create Desktop Entry".

First-time Startup

  1. 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.
  2. Customize PyCharm:

    • Choose your UI theme (Light or Dark).
    • Configure additional settings as needed.
  3. 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

  1. 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
  1. 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:

  • Open a Python interactive shell by typing python in your command line or terminal.
  • Run the following commands:

     import selenium
     print(selenium.__version__)
    

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.

  1. 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.
  2. 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()
  1. 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

  1. 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.
  2. Open Advanced System Settings:

    • In the System window, click on Advanced system settings on the left-hand side.
  3. Open Environment Variables:

    • In the System Properties window, click on the Environment Variables... button near the bottom.

Step 2: Edit the PATH Variable

  1. 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.
  2. 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.
  3. 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

  1. Open Command Prompt:

    • Press Win R, type cmd, and press Enter to open the Command Prompt.
  2. 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.


版本声明 本文转载于:https://dev.to/michael_chepala_7267688a0/installation-of-python-pycharm-selenium-and-web-drivers-509?1如有侵犯,请联系[email protected]删除
最新教程 更多>
  • Item 避免使用其他类型更合适的字符串
    Item 避免使用其他类型更合适的字符串
    1。避免使用字符串替代其他数据类型: 字符串旨在表示文本,但经常被误用来表示数字、枚举或聚合结构。 如果数据本质上是数字,请使用 int、float 或 BigInteger 等类型,而不是 String。 String age = "30"; // incorreto int age = 30;...
    编程 发布于2024-11-02
  • 如何使用sync.WaitGroup防止Go并发死锁?
    如何使用sync.WaitGroup防止Go并发死锁?
    解决 Goroutines 死锁在这种情况下,您在 Go 并发代码中遇到了死锁错误。让我们深入研究这个问题并提供一个有效的解决方案。该错误是由于生产者和消费者的行为不匹配而发生的。在生产者函数中实现的生产者在有限的时间内在通道 ch 上发送值。然而,存在于主函数中的消费者无限期地运行,无休止地尝试从...
    编程 发布于2024-11-02
  • 如何处理文本文件中的 Unicode 文本:无错误编写的完整指南
    如何处理文本文件中的 Unicode 文本:无错误编写的完整指南
    文本文件中的 Unicode 文本:无错写作综合指南从 Google 文档中提取的编码数据可能具有挑战性,尤其是当遇到需要转换为 HTML 使用的非 ASCII 符号时。本指南提供了处理 Unicode 文本并防止编码错误的解决方案。最初,在数据检索期间将所有内容转换为 Unicode 并将其写入文...
    编程 发布于2024-11-02
  • EchoAPI 与 Insomnia:结合实例进行综合比较
    EchoAPI 与 Insomnia:结合实例进行综合比较
    作为一名全栈开发人员,我知道拥有一流的工具来调试、测试和记录 API 是多么重要。 EchoAPI 和 Insomnia 是两个出色的选项,每个选项都有自己独特的特性和功能。让我带您了解这些工具,比较它们的功能和优点,给您一些实际示例,并帮助您决定何时使用 EchoAPI 或 Insomnia。 ...
    编程 发布于2024-11-02
  • 出发时间和持续时间|编程教程
    出发时间和持续时间|编程教程
    介绍 本实验旨在测试您对 Go 的时间和持续时间支持的理解。 时间 下面的代码包含如何在 Go 中使用时间和持续时间的示例。但是,代码的某些部分丢失了。您的任务是完成代码,使其按预期工作。 Go编程语言基础知识。 熟悉 Go 的时间和持续时间支持。 $ go run...
    编程 发布于2024-11-02
  • 起重面试问答
    起重面试问答
    1. JavaScript 中什么是提升? 答案: 提升是执行上下文创建阶段为变量和函数分配内存的过程。在此过程中,为变量分配了内存,并为变量分配了值 undefined。对于函数,整个函数定义存储在内存中的特定地址,并且对其的引用放置在该特定执行上下文中的堆栈上。 ...
    编程 发布于2024-11-02
  • 了解 JavaScript 中的文档对象模型 (DOM)
    了解 JavaScript 中的文档对象模型 (DOM)
    你好,神奇的 JavaScript 开发者? 浏览器提供了一个称为文档对象模型 (DOM) 的编程接口,它允许脚本(特别是 JavaScript)与网页布局进行交互。网页的文档对象模型 (DOM) 是一种分层树状结构,它将页面的组件排列成对象,由浏览器在加载时创建。借助此范例,文档...
    编程 发布于2024-11-02
  • 开始使用 SPRING BATCH 进行编程
    开始使用 SPRING BATCH 进行编程
    Introduction Dans vos projets personnels ou professionnels, Il vous arrive de faire des traitements sur de gros volumes de données. Le traite...
    编程 发布于2024-11-02
  • 使用 CSS 让您的 Github 个人资料脱颖而出
    使用 CSS 让您的 Github 个人资料脱颖而出
    以前,自定义 Github 个人资料的唯一方法是更新图片或更改名称。这意味着每个 Github 配置文件看起来都一样,自定义它或脱颖而出的选项很少。 从那时起,您可以选择使用 Markdown 创建自定义部分。您可以包括您的简历、您的兴趣和爱好,让您的个人资料反映您的身份。这是任何人在访问您的个人资...
    编程 发布于2024-11-02
  • TypeScript 实用程序类型:增强代码可重用性
    TypeScript 实用程序类型:增强代码可重用性
    TypeScript 提供内置实用程序类型,允许开发人员有效地转换和重用类型,使您的代码更加灵活和 DRY。在本文中,我们将探讨关键实用程序类型,例如 Partial、Pick、Omit 和 Record,以帮助您将 TypeScript 技能提升到新的水平。 Partial:使所有属性可选 部分实...
    编程 发布于2024-11-02
  • 电报 window.open(url, &#_blank&#);在ios上工作很奇怪
    电报 window.open(url, &#_blank&#);在ios上工作很奇怪
    我正在制作一个电报机器人,我想添加将一些信息从小型应用程序转发到聊天的选项。我决定使用 window.open(url, '_blank');在我在 iPhone 上尝试之前它一直运行良好。我没有转发,而是分享(这是一件大事,我正好需要转发一条消息)。我有一些如何处理它的想法,但它们...
    编程 发布于2024-11-02
  • 谁是前端开发人员?
    谁是前端开发人员?
    当今互联网上每个网站或平台的用户界面部分都是前端开发人员工作的结果。他们参与创建用户友好的界面,确保网站的外观和功能。但到底谁是前端开发人员呢?我简单解释一下。 用户看到的部分是前端 打开网站时首先看到的是网页界面:颜色、按钮、文字、动画。这都是由前端开发人员创建的。前端是网站或应用...
    编程 发布于2024-11-02
  • 如何使用保留的 CSS 样式将 HTML 内容另存为 PDF?
    如何使用保留的 CSS 样式将 HTML 内容另存为 PDF?
    使用 CSS 将 HTML 内容保存为 PDF在 Web 开发中,即使将内容导出为不同格式,保持视觉美观也至关重要。当尝试将 HTML 元素另存为 PDF 时,这可能会带来挑战,因为 CSS 样式可能会在转换过程中丢失。对于必须在保存的 PDF 中保留 CSS 的情况,请考虑使用以下方法:创建新窗口...
    编程 发布于2024-11-02
  • 为什么使用 Print_r() 时要向 DateTime 对象添加幻像属性?
    为什么使用 Print_r() 时要向 DateTime 对象添加幻像属性?
    Print_r() 更改 DateTime 对象Print_r() 向 DateTime 对象添加属性,从而在调试期间启用自省。此行为是 PHP 5.3 中引入的内部功能的副作用,它将幻像公共属性分配给转储到文本的实例。要避免这些属性引起的错误,请改用反射。然而,不建议寻找这些属性,因为它们没有在类...
    编程 发布于2024-11-02
  • C 语言的数据结构和算法:适合初学者的方法
    C 语言的数据结构和算法:适合初学者的方法
    在 C 语言中,数据结构和算法用于组织、存储和操作数据。数据结构:数组:有序集合,使用索引访问元素链表:通过指针链接元素,支持动态长度栈:先进后出 (FILO) 原则队列:先进先出 (FIFO) 原则树:分级组织数据算法:排序:按特定顺序排序元素搜索:在集合中查找元素图形:处理节点和边之间的关系实战...
    编程 发布于2024-11-02

免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。

Copyright© 2022 湘ICP备2022001581号-3