16

Edit: the problem is Pycharm is not loading LD_LIBRARY_PATH environment variable. Everything works if I add this into Pychar's environment. Why isn't it loading it?

I'm having trouble importing modules for gnuradio. First, everything works if I just run the python file from the command line, and everything loads just fine in the interpreter. There is only a problem using pycharm. Furthermore, GNU Radio is installed correctly.

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

I added the python interpreter, and since the module loads fine from the interpreter I'm not sure why I had to add the path to pycharm. Anyways, I added the location where the the gnuradio module is: /usr/local/lib/python2.7/site-packages/gnuradio; however, it was wrong. The correct path to load was the parent directory: /usr/local/lib/python2.7/site-packages. I'm wondering why this is.

More importantly, after loading the library I get this compiler error:

File "/usr/local/lib/python2.7/site-packages/gnuradio/gr/runtime_swig.py", line 24, in swig_import_helper
    _mod = imp.load_module('_runtime_swig', fp, pathname, description)
ImportError: libgnuradio-pmt-3.7.2git.so.0.0.0: cannot open shared object file: No such file or directory

The file in question is located in /usr/local/lib, however I've added every possible path to tell it where it is but no luck. Also, I've added /usr/lib:/usr/local/lib to my LD_LIBRARY_PATH and ran ldconfig with no success. Only thing I could think of.

What am I doing wrong?

Again, everything works fine if I'm not using PyCharm. This is a question regarding Pycharm specifically.

Gahan
  • 4,075
  • 4
  • 24
  • 44
smurff
  • 2,431
  • 3
  • 13
  • 7
  • 1
    Post your imports from the script which is giving you problems. Also use `help()` then `modules` to list all the available modules. If your IDE has different ones available than the "cmd python" then that is your problem. – Aleksander Lidtke Nov 10 '13 at 15:51
  • Yes, help () modules many more modules than the IDE. How do I fix this? I loaded /usr/bin/python into pycharm, shich is the interpreter that I'm using – smurff Nov 10 '13 at 15:57
  • 1
    Could be that your IDE uses different Python modules directory. You can see where a given module is loaded from doing something like this: `import numpy; numpy.__file__` in both IDE and stand-alone Python. If the two are different you'll know what the problem is. As to how to set the Pycharm module path no idea, never used it. – Aleksander Lidtke Nov 10 '13 at 16:06
  • 1
    It is not, they are the same. Also, it wouldn't answer the shared library problem – smurff Nov 10 '13 at 16:13

3 Answers3

7

Did you tried to use virtual environments to setup interpreters on pycharm? if you need some libraries it has a package manager that lets you install libraries with a simple gui.

Let me show you a sample :

When you create a new project

enter image description here

Select the box on the right on interpreter

You will get a screen like this

enter image description here

click on the 3rd button next to the plus, minus and edit, the python logo with a "green v", then a dialog like this will appear :

enter image description here

click on ok and then the prior dialog will be updated like this :

enter image description here

Click on the install button a dialog with a repository list will appear, select the libraries you need and install on the virtual env interpreter.

markcial
  • 9,041
  • 4
  • 31
  • 41
0

In PyCharm, you can change the configuration of the file you are trying to run.

Steps to edit configuration using pycharm: 1. Right click on the file in project explorer of the pycharm. 2. Run the file. (This run file with import errors)enter image description here 3. There is a run icon at the top right corner of pycharm. Next to the arrow, there is an dropdown box. Click on the arrow and select 'Edit configurations ...'enter image description here 4. In the edit configuration window, change the python interpreter path to the path that has the package you need installed.enter image description here 5. Like the one shown in the last snapshot, if you have different version of python installed, the file needs to know which python version to run.enter image description here

Also, if you have both python2 and python3 installed in your machine and if you use pip install, it will install the packages under python2 directory. so you need to used pip3 install if you want your packages under python3 directory.

Uma Senthil
  • 423
  • 2
  • 5
  • 18
0

I faced the similar problem yesterday but on windows 8.1 platform with gnuradio-3.7 version. It seems that "_runtime_swig" is missing in gnuradio-3.7/lib/site-packages/gnuradio/gr directory, as stated under the raised issue https://github.com/gnuradio/gnuradio/issues/2637. A patch to this problem has been provided for gnuradio-3.8 version.

Upgrading my gnuradio version to 3.8 has installed the missing "_runtime_swig" under gnuradio-3.7/lib/site-packages/gnuradio/gr directory and then I had to fix the missing dependencies (DLL)s to this module by adding `C:\Program Files\gnuradio-3.8\bin' folder to the "Path" system variable by following the answer in ImportError: No module named _analog_swig

This might be helpful for someone else facing similar problem here. Cheers!

praneeth
  • 369
  • 4
  • 20