53

I want to be able to use the paraview.simple library in PyCharm. I already have paraview installed in my computer. This package cannot be installed with pip and there are no .whl files as far as I can tell. The website docs recommend that the directory containing all the python files be added to PYTHONPATH.

How do I add the relevant folder in PYTHONPATH on my PyCharm session, and keep it there by default, such that when I close out and reopen the paraview.simple library is still available?

1
  • If it is installed in your computer, try to reload all the python packages in pycharm
    – S Andrew
    Commented Feb 23, 2018 at 12:08

6 Answers 6

80

You can add custom paths this way.

  • Go to File->Settings->project Interpreter
  • In the Project-Interpreter field, click the down facing arrow and select "show All"
  • In that Menu, highlight your interpreter and then in the right menu, select the button "Show paths for the selected interpreter" (this is the last button)
  • click the plus symbol to add your path
0
43

Adding interpreter paths in PyCharm:

  1. Project Settings/Project Interpreter: select "settings" icon
  2. Project Interpreters: select "tree" icon
  3. Interpreter Paths: select "plus" icon

Screenshot

14

In PyCharm version 2020.3.1 use the following workflow instead (see official docs):

Ctrl+Alt+S - open Settings.

File|Settings|Project|Project Structure...

You will see project folder structure. Mark subfolders as Sources or Excluded

File|Settings|Project|Project Structure

3
  • This seems like the most straightforward way to go as of April 2021 Commented Apr 6, 2021 at 21:18
  • 2
    I don't think this works if the external file isn't part of your project. This interface only lets me mark folders that are in my project folder as sources. Commented May 13, 2021 at 21:01
  • This should be the accepted answer. While you could set the environment variable PYTHONPATH through other means such as .ENV file or define environment variables in the Configuration settings - I have found that doing it using the Settings --> Project Structure dialog (as shown in this answer) imparts more development time intelligence. i.e. PyCharm intellisense can detect your modules and carry out auto-complete, etc.
    – Sau001
    Commented Feb 13 at 22:47
2

For me, in PyCharm 2022.3.1 the way to do this was different than currently listed (though still similar).

  1. Press CTRL+ALT+S to open settings or go through the toolbar via File -> Settings

  2. Navigate to your Project settings, expand, and click "Python Interpreter"

  3. Click the drop down to show interpreters, and then click "Show All" Example of where the button is

  4. In the resulting popup, select the interpreter you want to add the path to, and then click the folder-tree icon

Toolbar example with folder tree button highlighted

In the newest pop up modal window you can add paths by clicking the + button and navigating to the path you want to include.

Add Path Image

1
  • Thanks, this is the only thing that worked for me. Everything regarding adding content roots etc. didn't seem to do anything at all..
    – fresskoma
    Commented Jun 30 at 21:18
1
  • Use anaconda with Pycharm
  • To install paraview with anaconda run the following command: conda install -c conda-forge paraview
  • If conda command is not recognized then register the Anaconda path to environment variable
  • Now open pycharm and give the configuration path as the Anaconda path
  • File -> Settings -> Project Interpreter
  • In Project Interpreter give similar path : "C:\Users\username\Anaconda3\python.exe"
0

For me this solved it: mapping the local path to the remote inside the Pycharm run configurations settings.

Edit Configurations > Path Mappings >

Local path = /<Users/me/pycharm etc.../project root> remote path = /

eg.

enter image description here

Not the answer you're looking for? Browse other questions tagged or ask your own question.