Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm and PYTHONPATH

Tags:

python

pycharm

I am new to PyCharm. I have a directory that I use for my PYTHONPATH: c:\test\my\scripts\. In this directory I have some modules I import. It works fine in my Python shell.

How do I add this directory path to PyCharm so I can import what is in that directory?

like image 573
Trying_hard Avatar asked Feb 04 '15 16:02

Trying_hard


People also ask

Does PyCharm use Pythonpath?

Pycharm does not use system PYTHONPATH – IDEs Support (IntelliJ Platform) | JetBrains. Please consider editing your post and mark it as obsolete instead.

How do I give a path in PyCharm?

Create a new path variablePress Ctrl+Alt+S to open the IDE settings and select Appearance & Behavior | Path Variables. and enter the name of the new variable (for example, DATA_PATH ) and its value that points to the target directory with the data file on your disk.

Should I add PyCharm to path?

Install PyCharm It is not important to change the installation destination of the PyCharm application, but you could also change the destination to be directly on your C: similarly to the Python installation. However, we suggest simply going with the default path.


2 Answers

Out of data, see Duane's answer below.

You need to go to the Main PyCharm Preferences, which will open up a separate window. In the left pane, choose Project:... > Project Interpreter. Now, in the main pane on the right, click the settings symbol (gear symbol) next to the field for "Project Interpreter". Choose More or Show All in the menu that pops up. Now in the final step, pick the interpreter you are using for this project and click on the tree symbol at the bottom of the window (hovering over the symbol reveals it as "Show paths for the selected interpreter"). Add your path by click in the "plus" symbol.

It took me ages to find, so I hope the detailed instructions will help. Further details are available in the PyCharm docs.

It is good practice to have __init__.py in each subfolder of the module you are looking to add, as well as making your project folder a 'Source Root'. Simply right-click on the folder in the path bar and choose 'Mark Directory as ...'

like image 110
Hendrik F Avatar answered Sep 23 '22 10:09

Hendrik F


For Pycharm Community 2019.3

  • File
  • Settings
  • Project
  • Project Interpreter
  • Cog in top right => Show all
  • Select the interpreter
  • On the right toolbar, there are 5 icons, bottom one looks like a folder tree, folder treeclick it
  • Press plus +
  • Select directory, press OK
like image 30
Duane Avatar answered Sep 22 '22 10:09

Duane