Fix Python – How do I activate a virtualenv inside PyCharm’s terminal?

I’ve set up PyCharm, created my virtualenv (either through the virtual env command, or directly in PyCharm) and activated that environment as my Interpreter. Everything is working just fine.
However, if I open a terminal using “Tools, Open Terminal”, the shell prompt supplied is not using the virtual env; I still have to use source ~/envs/someenv/….

Fix Python – Pycharm does not show plot

Pycharm does not show plot from the following code:
import pandas as pd
import numpy as np
import matplotlib as plt

ts = pd.Series(np.random.randn(1000), index=pd.date_range(‘1/1/2000’, periods=1000))

ts = ts.cumsum()
ts.plot()

What happens is that a window appears for less than a second, and then disappears again.
Using the Pyzo IEP IDE (u….

Fix Python – How can I tell PyCharm what type a parameter is expected to be?

When it comes to constructors, and assignments, and method calls, the PyCharm IDE is pretty good at analyzing my source code and figuring out what type each variable should be. I like it when it’s right, because it gives me good code-completion and parameter info, and it gives me warnings if I try to access an attribute that doesn’t exist.
But whe….

Fix Python – How do I configure PyCharm to run py.test tests?

I want to start writing unit tests for my Python code, and the py.test framework sounds like a better bet than Python’s bundled unittest. So I added a “tests” directory to my project, and added test_sample.py to it. Now I want to configure PyCharm to run all the tests in my “tests” directory.
PyCharm allegedly supports py.test in its test runner. ….

Fix Python – 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 Pycharm. Everything is installed and configured how I want it.
Gnuradio is located at /usr/local/lib/py….

Fix Python – 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 I noticed that using dict() it seems impossible to specify a numeric key .. d = {1: ‘one’, 2: ‘two’}….

Fix Python – 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 practice to access variable from the outer scope, but what is the problem with shadowing the outer scope….