PyCharm Project Add External Library (PyMySQL) Path Example

When i use PyCharm to develop Python example, i need to add a third-party library ( PyMySQL : A MySQL database Python driver library. ) into the Python project path, so that PyCharm can find the library files when coding and executing source code. This article will tell you how to add external libraries into PyCharm project, it is different from adding external library in eclipse pydev.

1. Add External Libraries In PyCharm Project On MacOS.

This example use PyCharm MacOS version, PyCharm Windows or Linux version is similar.

  1. Open PyCharm, click PyCharm —> Preferences menu item.
    macos pycharm preferences menu item
  2. Then click Project —> Project Interpreter menu item in left panel.
    macos pycharm preferences project interpreter
  3. Click the + button in right panel bottom left corner to popup the install third party library window.
    pycharm search and install third party python library window
  4. Input the library name in the search text box, select the library and click Install Package button to install it.
  5. When the installation process complete successfully, you can see the third-party library in the project interpreter package list. Click OK button to save the changes.
    installed python library in project interpreter library list
  6. If you want to add external libraries for new project in PyCharm, you can click File —> Preferences for New Projects menu item to open a popup window, then click Project Interpreter menu item in left panel, then install python library in right panel like above.

2. Installed Library Saved Location.

After install the third party Python library, you may want to know where the library is installed. In the PyCharm left project panel, select Project view and expand the External Libraries item, then you will find the installed pymysql library in the Python 3.6 —> site-packages folder. Now you can import and use pymysql library in your Python code edited with PyCharm.

pycharm project external libraries location

3. Install External Library For PyCharm Project On Linux Ubuntu.

  1. Click PyCharm File —> Settings menu item in top menu bar to open project Settings window.
  2. Then click Project : <project name> —> Project Interpreter menu item in left panel to list current project interpreter and the installed external libraries.
    pycharm settings window project interpreter list
  3. Click the + icon in right panel to open new external library installation window. Search and select related library package. Please note, you should check the Install to user’s site packages directory(/home/zhaosong/.local) checkbox, otherwise you can not find the library package in Project panel —> External Libraries.
    install new django external library in pycharm
  4. Now you can use the external library package in your Django code and find it in Project panel —> External Libraries —> Python 3.6 —> site-packages.
    pycharm django project external libraries site packages

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.