Working with PyCharm Features from Command Line
Besides working from within PyCharm, it is possible to perform certain actions "offline", without actually launching the IDE. This way you can:
- Launching a code inspection from the command line
- Examples
- Windows
- OS X
- Viewing differences
- Opening file in the editor
Launching a code inspection from the command line
To launch a code inspection from the command line
- Specify the following command line arguments:
- Path to the launcher: specify the full path
to one of the following launchers (which reside under the
bin
directory of your PyCharm installation):- For Windows:
inspect.bat
- For UNIX and OS X:
inspect.sh
- For Windows:
- Project file path is the full path to the directory that contains the project to be inspected.
- Inspection profile path is the full path to the
profile, against which the project should be inspected. The inspection profiles are stored
under
USER_HOME\.PyCharmXX\config\inspection
- Output path is the full path to an existing directory where the report will be stored.
- Options. You can specify:
- The directory to be inspected
-d <full path to the subdirectory>
- The verbosity level of output
-vX
, where X is 0 for quiet, 1 for noisy and 2 for extra noisy.
- The directory to be inspected
- Path to the launcher: specify the full path
to one of the following launchers (which reside under the
Examples
Windows
C:\Program Files (x86)\JetBrains\<PyCharm home>\bin\inspect.bat
E:\SampleProjects\MetersToInchesConverter E:\Work\MyProject\.idea\inspectionProfiles\Project_Default.xml
E:\Work\MyProject\inspection-results-dir -v2 -d E:\SampleProjects\MetersToInchesConverter\subdirectory
OS X
/Applications/PyCharm.app/Contents/bin/inspect.sh ~/PyCharmProjects/MyTestProject
~/Library/Preferences/pycharmXX/inspection/Default.xml ~/PyCharmProjects/MyTestProject/results-dir -v2
Viewing differences
To view differences using command line diff tool
- In the command line, type the following:
where:
<PyCharm> diff <path1> <path2>
- <PyCharm> is the platform-specific product launcher
-
<path1>, <path2>
are full paths to the files to be compared.
Examples
Windows
PyCharm.exe diff C:\SamplesProjects\MetersToInchesConverter\src\javascript\numbers.js
C:\SamplesProjects\MetersToInchesConverter\src\coffeescript\numbers.coffee
OS X
/Applications/PyCharm.app/Contents/MacOS/pycharm diff ~/Documents/file1.txt ~/Documents/file2.txt
Opening file in the editor
To open file for editing
- In the command line, type the following:
where:
<PyCharm> <path1> --line <number> <path2>
-
<PyCharm>
is the platform-specific product launcher -
<path1>
is the path to the project that contains the desired file -
<number>
is the number of the line, where the caret should rest -
<path2>
is the path to the file to be opened
-
Examples
Windows
PyCharm.exe C:\SamplesProjects\MetersToInchesConverter --line 3
C:\SamplesProjects\MetersToInchesConverter\src\javascript\numbers.js
OS X
/Applications/PyCharm.app/Contents/MacOS/pycharm ~/PyCharmProjects/untitled45 --line 1 ~/PyCharmProjects/untitled45/sample.sass
See Also
Last modified: 20 April 2016