简体   繁体   中英

Add directory to Python path in PyCharm?

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?

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

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

截图

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

文件|设置|项目|项目结构

  • 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"

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.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM