Pythonocc Import error Dll load failed - python-2.7

I am getting started with pythonocc i have tried to import some modules and return with the following errors
` Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from OCC.gp import *
File "C:\Python27\lib\site-packages\OCC\gp.py", line 28, in <module>
_gp = swig_import_helper()
File "C:\Python27\lib\site-packages\OCC\gp.py", line 24, in swig_import_helper
_mod = imp.load_module('_gp', fp, pathname, description)
ImportError: DLL load failed: The specified module could not be found.
`
i am using windows 64 bit python 2.7.3 32bit and pythonocc 0.5 all in one
What is the solution to the above probelm?

If you have 64 bit python, it can struggle to load 32 bit Dll's.
Try this link
I recommend getting a 32 bit distribution of python, this should solve your problem

Install pythonocc 0.6 from this link http://code.google.com/p/pythonocc/ this should work fine

At the following link you can find pythonOCC for Python 2.7:
http://code.google.com/p/pythonocc/downloads/list
Link was tested on 07/10/14

Related

Installing GDAL 2.1 64-bit for Python 2.7, Windows 7

Ah, yes, back to the joy of installing GDAL.
This time, I need to install GDAL 2.1 for Python 2.7, 64-bit, on Windows 7. I used these installers for the Python bindings and GDAL core, and set the appropriate path variables. I am using Numpy 1.10.4.
In the Command Prompt:
gdalinfo --version
> GDAL 2.1.0, released 2016/04/25
In Python:
>>> Python 2.7.11 ... MSC v.1500 64 bit(AMD64) on win32
from osgeo import gdal
gdal.__version__
>>> '2.1.0'
So far, so good. But, it fails to find _gdal_array.pyd when trying to read a dataset to a Numpy array:
ds = gdal.Open("test.tif")
data = ds.ReadAsArray()
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
ds.ReadAsArray()
File "C:\Python27\lib\site-packages\osgeo\gdal.py", line 1825, in ReadAsArray
import gdalnumeric
File "C:\Python27\lib\site-packages\osgeo\gdalnumeric.py", line 1, in <module>
from osgeo.gdal_array import *
File "C:\Python27\lib\site-packages\osgeo\gdal_array.py", line 26, in <module>
_gdal_array = swig_import_helper()
File "C:\Python27\lib\site-packages\osgeo\gdal_array.py", line 18, in swig_import_helper
import _gdal_array
ImportError: No module named _gdal_array
Has anyone been able to install GDAL 2.1 successfully on a 64-bit system?
If you downloaded from source and installed numpy just after the build. You need to rebuild e reinstall the gdal/swig/python.
Hope it helps!

Problems with CPLEX Python API on a mac

I have read many posts about problems but none of them can solve mine. Although I have been following this blog exactly I still get this error when I try to run one of the example src python files:
Traceback (most recent call last):
File "facility.py", line 25, in <module>
import cplex
File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/__init__.py", line 43, in <module>
import callbacks
File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/callbacks.py", line 48, in <module>
from _internal._aux_functions import apply_freeform_two_args, apply_freeform_one_arg
File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/__init__.py", line 22, in <module>
import _list_array_utils
File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/_list_array_utils.py", line 13, in <module>
import _pycplex as CPX
File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/_pycplex.py", line 19, in <module>
_pycplex_platform = swig_import_helper()
File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/_pycplex.py", line 15, in swig_import_helper
_mod = imp.load_module('_pycplex_platform', fp, pathname, description)
File "/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/_pycplex_platform.py", line 23, in <module>
from cplex._internal.py1013_cplex1251 import *
ImportError: dlopen(/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/py1013_cplex1251.so, 2): no suitable image found. Did find:
/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/cplex/_internal/py1013_cplex1251.so: mach-o, but wrong architecture
Unfortunately I am not familiar with the /.bash_profile but what is posted in the link I added at the end.
Can please someone help me out here?
A possible solution to this would be to check whether you can copy the cplex directory manually over towards the site-packages that are installed (you may need to use sudo).
From your stacktrace I see that you have installed cplex into
/Users/sb/Applications/IBM/ILOG/CPLEX_Studio1251/cplex/python/x86_darwin/
First run (I assume you python 2.7) in the interactive shell:
import site; site.getsitepackages()
See How do I find the location of my Python site-packages directory? for details about this step.
This will give you the directory of the site-packages where you need to copy the "cplex" directory to. I assume it is /Library/Python/2.7/site-packages from here
on a mac then run:
sudo cp -r ./cplex /Library/Python/2.7/site-packages/
This sets up the cplex manually as an importable package for your python installation. You should therefore be able to import cplex within the python interactive shell.

Leap Motion Python SDK with conda

I am using an anaconda's python 2.7 distribution as my default python distribution. I receive a
Fatal Python error: PyThreadState_Get: no current thread
This error seems to be a result of a python distribution conflict; I am using anconda's python distribution but Leap motion's sdk anticipates the default mac distribution.
I followed Leap motion's sdk instructions on changing the default python distribution as follows,
install_name_tool -change /Library/Frameworks/Python.framework/Versions/2.7/Python
//anaconda/bin/python LeapPython.so
But now I receive the following error, which I have not been able to make much of,
Traceback (most recent call last):
File "Sample.py", line 9, in <module>
import Leap, sys, thread, time
File "/Users/jkarimi91/Documents/Projects/hackingedu/LeapDeveloperKit_2.3.1+31549_mac/LeapSDK/lib/Leap.py", line 28, in <module>
LeapPython = swig_import_helper()
File "/Users/jkarimi91/Documents/Projects/hackingedu/LeapDeveloperKit_2.3.1+31549_mac/LeapSDK/lib/Leap.py", line 24, in swig_import_helper
_mod = imp.load_module('LeapPython', fp, pathname, description)
ImportError: dlopen(/Users/jkarimi91/Documents/Projects/hackingedu/LeapDeveloperKit_2.3.1+31549_mac/LeapSDK/lib/LeapPython.so, 2): Library not loaded: //anaconda/bin/python
Referenced from: /Users/jkarimi91/Documents/Projects/hackingedu/LeapDeveloperKit_2.3.1+31549_mac/LeapSDK/lib/LeapPython.so
Reason: no suitable image found. Did find:
//anaconda/bin/python: can't map unslidable segment __TEXT to 0x100000000 with size 0x1000
I think the problem is that you are trying to load the Python executable, not the shared library. Since Anaconda doesn't seem to give you a framework, try replacing /anaconda/bin/python in your command with /anaconda/pkgs/python-2.7.10.0 or if that doesn't work, specify the full path to the Python dylib /anaconda/pkgs/python-2.7.10.0/lib/libpython2.7.dylib.

What should I modify to solve the "No module named _sqlite3" error message?

I installed ATpy-0.9.7 on my pc successfully and I also have the Python version of "2.7.5".
But when I import atpy I get the following error message:
>>> import atpy
ERROR: ImportError: No module named _sqlite3 [unknown]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "atpy/__init__.py", line 1, in <module>
from .basetable import Table, TableSet, VectorException
File "atpy/basetable.py", line 15, in <module>
from . import registry
File "atpy/registry.py", line 186, in <module>
from . import sqltable
File "atpy/sqltable.py", line 10, in <module>
from . import sqlhelper as sql
File "atpy/sqlhelper.py", line 11, in <module>
import sqlite3
File "/export/aibn84_2/zahra/lib/Python-2.7.5/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/export/aibn84_2/zahra/lib/Python-2.7.5/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
I also installed db_sqlite3.egg-info. I don't know why this error message occurs!
I installed again th python2.7.5 with the following command :
./configure --prefix=$PYTHONPATH
but I also get this error after executing make:
Python build finished, but the necessary bits to build these modules were not found:
_bsddb _sqlite3 bsddb185
dbm dl gdbm
imageop sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
How could I run configure in order to install required C libraries?
If you are using a self built version of Python you need to ensure that both the base and the development sqllite3 packages are installed on your system before building Python.
If they are not and, as you said, you do not have superuser privileges, you can download and build sqlite locally, and get your Python build to use that version. This blog post describes how.
According to this question
How can I install sqlite3 to Python?
...you shouldn't have to install anything to get sqlite3 for python. Before I could import atpy I did have to install astropy (which was quite involved). After I did that, everything worked.

py2exe with enthought and pandas

I am trying to make an executable with python, py2exe using Enthought. The program.py starts with:
import pandas as pd
import pyper as pr
r=pr.R(use_pandas=True)
The setup.py is as below:
from distutils.core import setup
import py2exe
import matplotlib
import sys
opts={"py2exe":{"bundle_files"}}
sys.argv.append('py2exe')
opts = {'py2exe': {"bundle_files" : 3, "includes" : [ "matplotlib.backends", "matplotlib.backends.backend_qt4agg", "pylab","numpy", "matplotlib.backends.backend_tkagg"], 'excludes':['_gtkagg', '_tkagg', '_agg2', '_cairo', '_cocoaagg', '_fltkagg', '_gtk', '_gtkcairo'], 'dll_excludes': ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll']}}
setup(console=['program.py'],zipfile=None,options=opts,data_files=matplotlib.get_py2exe_datafiles())
After running:python setup.py py2exe the two folders dist and build were created. But when launched program.exe I got this:
Dll load failed: The specified module could not be found
Traceback (most recent call last):
File "program.py", line 1, in module
File "pandas\__init__.pyc", line 6, in module
File "pandas\hashtable.pyc", line 12, in module
File "pandas\hashtable.pyc", line 10, in module
File "numpy.pxd.", line 157, in init pandas.hastable (pandas\hastable.c:19547)
File "numpy\__init__.pyc", line 143, in module
File "numpy\lib\add_newdocs.pyc", line 9, in module
File "numpy\lib\__init__.pyc", line 13, in module
File "numpy\lib\polynomial.pyc", line 17, in module
File "numpy\linalg\__init__.pyc", line 48, in module
File "numpy\linalg\linalg.pyc", line 23, in module
File "numpy\linalg\lapack_lite.pyc", line 12, in module
File "numpy\linalg\lapack_lite.pyc", line 10, in __load
ImportError: DLL load failed: The specified module could not be found**
I'm using Canopy 1.1.0 with Pandas 0.12.0-2 on a 64-Windows 7
Thanks for any help.
It looks as though the .exe built by py2exe may be missing the Intel MKL DLLs that come with Canopy (EPD). Depending on which version of Canopy (EPD) you have, the NumPy DLLs may be linked against the Intel MKL DLLs. Those DLLs should be in C:\Python27\Scripts directory (or the corresponding Scripts directory if you've installed EPD in a different place) -- look for DLLs whose filename starts with mk2.
EDIT: The path above works only for older EPD versions. For a more recent version of Canopy, the DLLS are typically located somewhere like C:\Users\<user>\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.1.0-1371-win-x86_64\Scripts