Questions tagged [pycharm]

PyCharm is an integrated development environment (IDE) for Python. It is developed by JetBrains for Windows, Mac OS X and Linux. DO NOT use this tag on questions regarding code which merely happens to be written using PyCharm, use the appropriate language tag [python] instead.

PyCharm is an integrated development environment (IDE) for Python, developed by JetBrains. It is available on Windows, OS X and Linux.

It provides support for common Python frameworks such as Django, Flask, Pyramid and others.

Starting with version 3, a free and open-source edition of PyCharm was released; along with a professional (paid) edition.

If you have found a bug, it is usually better to report it at the public bug tracker.

For more information, browse the following:

  1. The official product page.
  2. The public bugtracker.
  3. Product blog.
  4. Support page.
16686 questions
1188
votes
9 answers

How do I type hint a method with the type of the enclosing class?

I have the following code in Python 3: class Position: def __init__(self, x: int, y: int): self.x = x self.y = y def __add__(self, other: Position) -> Position: return Position(self.x + other.x, self.y +…
Michael van Gerwen
  • 12,011
  • 3
  • 11
  • 8
543
votes
29 answers

Unresolved reference issue in PyCharm

I have a directory structure ├── simulate.py ├── src │   ├── networkAlgorithm.py │   ├── ... And I can access the network module with sys.path.insert(). import sys import os.path sys.path.insert(0, "./src") from networkAlgorithm import…
prosseek
  • 182,215
  • 215
  • 566
  • 871
475
votes
31 answers

"UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure." when plotting figure with pyplot on Pycharm

I am trying to plot a simple graph using pyplot, e.g.: import matplotlib.pyplot as plt plt.plot([1,2,3],[5,7,4]) plt.show() but the figure does not appear and I get the following message: UserWarning: Matplotlib is currently using agg, which is a…
johnwolf1987
  • 10,603
  • 3
  • 14
  • 17
396
votes
8 answers

How do I set the maximum line length in PyCharm?

I am using PyCharm on Windows and want to change the settings to limit the maximum line length to 79 characters, as opposed to the default limit of 120 characters. Where can I change the maximum amount of characters per line in PyCharm?
Ansuman Bebarta
  • 7,011
  • 6
  • 27
  • 44
339
votes
31 answers

PyCharm shows unresolved references error for valid code

I am using PyCharm to work on a project. The project is opened and configured with an interpreter, and can run successfully. The remote interpreter paths are mapped properly. This seems to be the correct configuration, but PyCharm is highlighting…
James McCalden
  • 3,696
  • 2
  • 16
  • 18
328
votes
11 answers

What is the problem with shadowing names defined in outer scopes?

I just switched to PyCharm and I am very happy about all the warnings and hints it provides me to improve my code. Except for this one which I don't understand: This inspection detects shadowing names defined in outer scopes. I know it is bad…
Framester
  • 33,341
  • 51
  • 130
  • 192
318
votes
2 answers

Simplify Chained Comparison

I have an integer value x, and I need to check if it is between a start and end values, so I write the following statements: if x >= start and x <= end: # do stuff This statement gets underlined, and the tooltip tells me that I must simplify…
Brynn McCullagh
  • 4,083
  • 2
  • 17
  • 12
274
votes
7 answers

How to make PyCharm always show line numbers

I cannot seem to be able to find the setting to enable line numbers for all files, but I have to always right click and enable this on per file basis. There must be a global setting for this, right?
Kimvais
  • 38,306
  • 16
  • 108
  • 142
267
votes
3 answers

How to navigate through the source code by parts in CamelCase (instead of whole words)?

I remember when I was using Eclipse that when holding CTRL and using left or right arrows Eclipse would navigate over the LongCamelCaseWrittenWord in several steps. One camel case word at time. So it will go like follows (pipe | represents the…
Jan Zyka
  • 17,460
  • 16
  • 70
  • 118
253
votes
5 answers

How do I annotate types in a for-loop?

I want to annotate a type of a variable in a for-loop. I tried this but it didn't work: for i: int in range(5): pass What I expect is working autocomplete in PyCharm 2016.3.2, but using pre-annotation didn't work: i: int for i in range(5): …
grepcake
  • 3,960
  • 3
  • 16
  • 26
246
votes
13 answers

Is there a difference between using a dict literal and a dict constructor?

Using PyCharm, I noticed it offers to convert a dict literal: d = { 'one': '1', 'two': '2', } into a dict constructor: d = dict(one='1', two='2') Do these different approaches differ in some significant way? (While writing this question…
maligree
  • 5,939
  • 10
  • 34
  • 51
233
votes
10 answers

Why does PyCharm propose to change method to static?

The new pycharm release (3.1.3 community edition) proposes to convert the methods that don't work with the current object's state to static. What is the practical reason for that? Some kind of micro-performance(-or-memory)-optimization?
zerkms
  • 249,484
  • 69
  • 436
  • 539
233
votes
13 answers

Word wrapping in PhpStorm

How can I enable word wrapping in PhpStorm? I need to enable it only for some of my files (with extension .txt). Is it possible?
ozahorulia
  • 9,798
  • 8
  • 48
  • 72
216
votes
14 answers

How do I use installed packages in PyCharm?

In PyCharm, I've added the Python environment /usr/bin/python. However, from gnuradio import gr fails as an undefined reference. However, it works fine in the Python interpreter from the command line. GNURadio works fine with python outside of…
smurff
  • 2,431
  • 3
  • 13
  • 7
213
votes
5 answers

Why does Pycharm's inspector complain about "d = {}"?

When initializing a dictionary with d = {} Pycharm's code inspector generates a warning, saying This dictionary creation could be rewritten as a dictionary literal. If I rewrite it d = dict() the warning goes away. Since {} already is a dictionary…
Chris Sears
  • 6,502
  • 5
  • 32
  • 35
1
2 3
99 100