Asked  7 Months ago    Answers:  5   Viewed   66 times

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/python2.7/site-packages/gnuradio

Also:

PYTHONPATH=/usr/local/lib/python2.7/site-packages:/usr/local/lib/python2.7/site-packages/gnuradio

 Answers

81

Adding a Path

Go into File ? Settings ? Project Settings ? Project Interpreter.

Then press configure interpreter, and navigate to the "Paths" tab.

pycharm path tab

Press the + button in the Paths area. You can put the path to the module you'd like it to recognize.

But I don't know the path..

Open the python interpreter where you can import the module.

>> import gnuradio
>> gnuradio.__file__
"path/to/gnuradio"

Most commonly you'll have a folder structure like this:

foobarbaz/
  gnuradio/
    __init__.py
    other_file.py

You want to add foobarbaz to the path here.

Tuesday, June 1, 2021
 
Baba
answered 7 Months ago
63

(1) Yes, you are mostly correct.

The python_stubs file is an automatically generated file that contains dummy definitions for built-in functions. It is used by PyCharm to infer the types of the built-in functions in the case that they weren't hardcoded for the given version.

(3) It isn't always possible to correctly infer the type of a built-in functoin only from his docs. Some docstrings start with the "type signature":

>>> print(min.__doc__)
min(iterable[, key=func]) -> value
min(a, b, c, ...[, key=func]) -> value

but pickle.load() doesn't.

Note that this will probably change in future python versions, because starting with python3.4 the Argument Clinic was introduced which allows better inspection for built-ins defined in C. I'm not sure whether PyCharm is already able to get that information.

(2) Try rebuilding the python skeletons. However, AFAIK, the only real option, if this doesn't work, is to open a ticket on PyCharm's issue tracker.

Wednesday, July 28, 2021
 
binoculars
answered 5 Months ago
28

Setting the IDE default interpreter fixed the problem, as Vadim mentioned. Found instructions on how to do that here.

File | Default Settings | Project Interpreter.

This configuration sets the default interpreter for the new projects, note the Default Settings menu, it's not the same as File | Settings which sets options for the current project.

Not entirely sure why the default was unset, but at least now I can set it back again. The project default setting was being forgotten as well which is curious, but a problem for another day.

Thank you SO for helping to solve a problem in 14 minutes, which would have taken half a day trawling through the web or waiting for supporting requests.

Thursday, July 29, 2021
 
PLPeeters
answered 5 Months ago
22

You should be pointing your Project Interpreter to the virtualenv python bin. So in PyCharm File->Settings->Project: ProjectName->Project Interpreter, then a windows showing the Project Interpreter should be displayed.

Project Interpreter

Next to the top dropdown is a gear and your going to want to Add Local and navigate to the virtualenvs python bin. Something like virtualenvs/virtualenv_name/bin/python. Then your project should be pointing to the right place.

Sunday, August 8, 2021
 
wenjiehu
answered 4 Months ago
100

In case anyone is wondering, the Register is correct, my photo user control tag was just not formed properly. I did have it as:

<ssctrl:photo ID="Photo" Key="<%# Eval("PageTemplatePK") %>" runat="server" />

and the Key property needed to use single quotes instead of double quotes because it was using an Eval expression:

<ssctrl:photo ID="Photo" Key='<%# Eval("PageTemplatePK") %>' runat="server" />

After that, it worked.

Saturday, November 6, 2021
 
Awais Qarni
answered 1 Month ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :  
Share