'undefined symbol' error when importing C++ module - python

I have a python script which runs another python script and this latter script imports a module. It fails to do so and returns the following:
Traceback (most recent call last):
File "/some/path/script.py", line 13, in
import Autodock as AD
File "/some/path/to/module/Autodock.py", line 30, in
import BALL
File "/usr/lib/pymodules/python2.7/BALL.py", line 1, in
from BALLCore import *
ImportError: /usr/lib/pymodules/python2.7/BALLCore.so: undefined symbol: _ZN4BALL25FragmentDistanceCollectorclERNS_9CompositeE
However it gets loaded successfully when I just open the python interpreter and enter this:
>>> from BALLCore import *
Other scripts which also run /some/path/to/module/Autodock.py (which is the script importing the module) run successfully. What makes them successfully import the module from the same module-path?
I need to excuse myself for not sharing so much code, because I have no clue where to look. Any guidance would be appreciated.

Related

Running python file within a shell script : module not found error

I'm beginner to both bash and python.
I'm working in Ubuntu env.
to be short, I've created a shell script 'format_data.sh' that runs python file 'proc_ko.py' within it.
#!/bin/bash
...
python path/to/python/file/proc_ko.py
...
And the python file 'proc_ko.py' imports a module called khaiii
from khaiii import KhaiiiApi
api = KhaiiiApi()
...
But when I try to execute 'format_data.sh', I get this import error from python file.
Traceback (most recent call last):
File "media/sf_projet/pe/pe/PROGRAMME/SCRIPTS/proc_ko.py", line 5, in
from khaiii import KhaiiiApi
ImportError: No module named khaiii
which doesn't occur when I execute python file independently.
Python file 'proc_ko.py' itself doesn't have any error and 'khaiii' is well installed.
so I don't understand why import error occurs only through the shell script.
If u need more details to figure out, I'll be happy to provide. Thanks in advance for help.

Can't import qgis module to run python scripts external to QGIS

I am unsuccessful in running a QGIS python script (generated and working in QGIS and then saved as a python script). At the moment I am not fussed about the functions it is calling as can't even get to a standard print statement. The bigger picture is to migrate from running all my code using ESRI functionality to QGIS
I'm not getting past this stage:
from qgis.core import *
print("from qgis.core import *")
The error is:
*Traceback (most recent call last):
File "X:\10_Misc\Basic_Test.py", line 9, in <module>
from qgis.core import *
ImportError: No module named qgis.core*
Any ideas?
I have made changes to my python libraries as advised here:
https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/intro.html#using-pyqgis-in-standalone-scripts
Thanks in advance

How to add python library to Spyder

I am trying to add an external python library from a third party software into Spyder so I can work with it. I have already tried the following:
Adding library path containing .py files to Tools>PYTHONPATH manager
Synchronizing the path
Updating module names list through Tools>Update Module names list
However, when I try to import modules from this library I get two types of errors:
import easy
Traceback (most recent call last):
File "<ipython-input-2-685519d35f15>", line 1, in <module>
import easy
File "C:\Program Files (x86)\Plaxis\PLAXIS 2D\plxscripting\easy.py", line 24, in <module>
from .server import Server, InputProcessor
ValueError: Attempted relative import in non-package
The second type of error as follows:
from plxscripting.easy import *
Traceback (most recent call last):
File "<ipython-input-1-a40c101d3bb0>", line 1, in <module>
from plxscripting.easy import *
ImportError: No module named plxscripting.easy
I don't understand why Spyder is not recognizing these libraries. The path has been added and shows up on the manager. What constitutes a python module? Is it not just the .py file with module name prefix? Is not the path sufficient to work with the library through the IDE?

Python error: No module named RuntimeError

Im trying to figured out this problem. Yesterday I installed PyScripter and since then, scripts doesnt work. When I run any script (in PyScripter or IDLE) and trying to "import arcpy", it gets this error:
import arcpy
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import arcpy
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\__init__.py", line 17, in <module>
from geoprocessing import gp
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\__init__.py", line 14, in <module>
from _base import *
File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 14, in <module>
import arcgisscripting
File "C:\Python26\ArcGIS10.0\lib\arcgisscripting.py", line 81, in <module>
from RuntimeError import RuntimeError
ImportError: No module named RuntimeError
Have somebody any suggestion how to fix it?
Thanks to all very much!
Sounds like the module is not installed properly (or at all). To verify, do the following:
open a shell and start the python shell by typing python
(If this doesn't display an error, check that python is added to your system path or if it is even installed at all. But if you've used Python on said machine maybe system path issue)
enter the commmand help('modules')
review the list of modules that's returned to see whether arcpy is included
if not, then you may have to reinstall the module

Import 3rd party module in SublimeREPL

So I am learning to use SublimeREPL, and I encounter a problem.
I have a main.py file, and in the same folder a timer.py. I write import statement in the main.py:
import timer
Then if I open
1) SublimeREPL --> Python --> Python--IPython, and transfer the code to the InteractiveConsole, I get error:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "<string>", line 1, in <module>
ImportError: No module named timer
2) SublimeREPL --> Python --> Python, and transfer the code to the REPL console, it runs as expected.
I wonder what is the reason?
This is because the sys.path doesn't contain the given directory. You can edit this through the code below
import os
import sys
sys.path.append(os.getcwd())
# os.getcwd() is the current directory, make sure it's the right one.
This will make it possible to import timer.py

Categories