Following this source I would like to install METIS and the Python wrapper in colab:
https://github.com/james77777778/metis_python
The installation steps are listed as the following:
Download and extract metis-5.1.0.tar.gz from METIS - Serial Graph Partitioning and Fill-reducing Matrix Ordering
cd metis-5.1.0
make config shared=1 prefix=~/.local/
make install
export METIS_DLL=~/.local/lib/libmetis.so
pip3 install metis-python
However, I'm not sure how to do steps 2-4 in colab specifically and so I get the following error:
RuntimeError: Could not locate METIS dll. Please set the METIS_DLL environment variable to its full path.
Thanks!
The issue seems to be the location of the libmetis.so file. Copying the file to /usr/lib and updating the path for the environmental variable successfully completes the process:
import requests
import tarfile
# Download and extract the file
url = "http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/metis-5.1.0.tar.gz"
response = requests.get(url, stream=True)
file = tarfile.open(fileobj=response.raw, mode="r|gz")
file.extractall(path=".")
# Change working directory
%cd metis-5.1.0
# The remaining steps as you have shown in the question, with updated path
!make config shared=1 prefix=~/.local/
!make install
!cp ~/.local/lib/libmetis.so /usr/lib/libmetis.so
!export METIS_DLL=/usr/lib/libmetis.so
!pip3 install metis-python
import metispy as metis
Related
I've created a python tool and want to install it via brew. Creating the formula worked fine at first when i simply had one python file named myTool. Then i seperated the code into more files as it became larger and more complex.
How do i set up the install to bundle those files, because right now the imports are failing because the other files are not found.
My current install
def install
bin.install 'myTool'
end
The error shown when running the brew installed tool
from myModule import someFunc, someOtherFunc ModuleNotFoundError: No module named 'myModule'
The current setup only installs the angler file without any of the other python modules. This results in the ModuleNotFoundError error. Here is my suggestion:
def install
# Determines the python version being used
# e.g. If python3.10, xy = 3.10
xy = Language::Python.major_minor_version "python3"
# Where to install the python files
packages = libexec/"lib/python#{xy}/site-packages/angler"
# For each file present, install them in the right location
%w[angler anglerEnums.py anglerGen.py anglerHelperFunctions.py].each do |file|
packages.install file
end
# Create a symlink to the angler python file
bin.install_symlink packages/"angler"
end
I have a python file using OpenCV library.I want this in as an executable file.
Came across this cx_freeze
Example:
ABC.py(file using opencv library)
Content of setup.py is given below
from cx_Freeze import setup, Executable
setup( name = "ABC",
version = "0.1",
description = "Testing",
executables = [Executable("ABC.py")],
)
I ran this command in the terminal
python setup.py install
It is stopping after showing this error message
copying /Users/name/.virtualenvs/test/lib/python3.6/site-packages/cv2.so -> build/exe.macosx-10.12-x86_64-3.6/lib/cv2.so
copying /Users/name/.virtualenvs/test/bin/../lib/libopencv_reg.3.3.dylib -> build/exe.macosx-10.12-x86_64-3.6/libopencv_reg.3.3.dylib
error: [Errno 2] No such file or directory: '/Users/name/.virtualenvs/test/bin/../lib/libopencv_reg.3.3.dylib'
I know from the error message that libopencv_reg.3.3.dylib is not found.
I'm running this on a python virtual environment.
This is my bash_profile content
#Homebrew
export PATH=/usr/local/bin:$PATH
#export WORKON_HOME=$HOME/.virtualenvs
# Virtualenv/VirtualenvWrapper
source /usr/local/bin/virtualenvwrapper.sh
#export PROJECT_HOME=$HOME/Devel
#export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
#export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
#export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
I'm confused please help me out fix this.
Guidance would really be helpful, if this question can be posted else where let me know rather than down voting it.
can you search your filesystem for the missing file? When you find it you can set PERL5LIB or use -I switch to set the location into the perl path
perl library path
Shared the same on OpenCV forum
here's the response I got there
Looks like we have build OpenCV in such a way that other shared objects(.so) files are not dependent.
I am using Python 2.7 through Anaconda 2.7.8 and need Kapteyn 2.2 to perform Non-linear Least Squares fitting easily (it is probably an alternative to Scipy.optimize.leastsq() for dummies like me!).
After copy-pasting this from a previous post here on Stack Overflow:
conda install -c https://conda.binstar.org/dhirschfeld pyodbc
and then running on my cmd (as I did not have pyodbc installed I think, because of which maybe the command prompt on my Windows 7 64-bit system was not responding well to python setup.py install inside the Anaconda directory where I unzipped the Kapteyn .zip file downloaded from University of Groningen website.
But, after the installing pyodbc properly and running python setup.py install, the cmd gave me an error saying error: command 'C:\Users\windows 7\Anaconda\Scripts\gcc.bat' failed with exit status 1. Later, when I tried to import kmpfit module (needed for Non-linear least square fitting with Kapteyn), here is the problem:
import kapteyn
help(kapteyn)
Help on package kapteyn:
NAME
kapteyn - Kapteyn package.
FILE
c:\users\windows 7\anaconda\kapteyn\__init__.py
PACKAGE CONTENTS
_ni_support
celestial
doccer
filters
interpolation
maputils
mplutil
positions
rulers
shapes
tabarray
wcsgrat
DATA
__all__ = ['celestial', 'wcs', 'wcsgrat', 'tabarray', 'maputils', 'mpl...
__version__ = '2.2'
VERSION
2.2
As you can see, there is no module named kmpfit (or even wcs) here. But according to http://www.astro.rug.nl/software/kapteyn/intro.html, these two should be there.
Kindly help. I have never imported any module before.
Thanks in advance...:-)
I just managed to get this working (on Mac OSX, so you may have to adjust this). My steps were:
$ conda install pyodbc (didn't need to go through binstar)
Download & unarchive the kapteyn package, then navigate to its directory
$ python setup.py install, which used my OS's C compiler and Anaconda's python, and installed kapteyn to my anaconda distro's site-packages, as it should.
Check that kmpfit.so is in the kapteyn folder in site-packages, showing that kmpfit installed correctly.
>> from kapteyn import kmpfit failed, ImportError: cannot import name kmpfit. I did some digging and discovered that it was still importing kapteyn from the folder that I downloaded, not from site-packages.
Delete the downloaded kapteyn folder, then try again. It worked!
I am attempting to install M2Crypto on a Windows XP platform. I have Python, easy_install and SWIG installed, but when I attempt to easy_install M2Crypto I get the following:
SWIG\_m2crypto.i(31) : Error: Unable to find 'openssl\opensslv.h'
SWIG\_m2crypto.i(45) : Error: Unable to find 'openssl\safestack.h'
SWIG\_evp.i(12) : Error: Unable to find 'openssl\opensslconf.h'
SWIG\_ec.i(7) : Error: Unable to find 'openssl\opensslconf.h'
error: Setup script exited with error: command 'swig.exe' failed with exit status 1
I have read elsewhere that people have suggested easy_install openssl-devel, but that simply tells me that there are no packages found with that name. Is the name perhaps case-sensitive (I've tried various permutations without success), or does that advice not apply to Windows?
I'm not looking for alternatives to M2Crypto. I am picking up some existing code that uses it, so I need to get my development environment to be able to run what's already written.
As jay stated in his answer you should try to build it from source. And I tried. The setup.py does not recognize the --openssl option. Looking at the output from the default setup.py I realized that the search location was c:\pkg and not c:\pkg\openssl.
The solution:
Download and install OpenSSL from Win32 OpenSSL
Copy the lib and include folders to c:\pkg
Check that swig.exe is available in your path
Run easy_install M2Crypto
Worked for me like a charm.
Had a similar problem. After downloading the source package of M2Crypto and reading the INSTALL file I found the following:
Differences when installing on Windows
--------------------------------------
Before building from source, you need to install OpenSSL's include files,
import libraries and DLLs. By default setup.py assumes that OpenSSL include
files are in ``c:\pkg\openssl\include``, and the import libraries
in ``c:\pkg\openssl\lib``. As with other platforms, you can specify a different
OpenSSL location with --openssl option to build_ext command.
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
options = {'py2exe': {'bundle_files': 1}},
windows = [{'script': "single.py"}],
zipfile = None,
)
in this setup file for py2exe where it says single.py is that where I place the name of my program?
I don't know your py2exe tool, but we usually use this way to convert py to exe:
Download and install Standard Python Software:
http://www.python.org/download/
Download PyInstaller via link below:
http://pyinstaller.python-hosting.com/
Unpack the archive, that you have downloaded!
In this examople, the directory of the unpacked files:
In the <UNPACKED_FILES_DIR> directory, run Configure.py.
It must be run before trying to build anything.
Create a spec file for your project:
python Makespec.py -F -p <PYTHON_LIB_PATH> <PYTHON_SCRIPT>
-F: Produce a single file deployment.
-p <PYTHON_LIB_PATH>: Set base path for import (like using PYTHONPATH).
( e.g.: C:\Program Files\Python24\Lib\ )
<PYTHON_SCRIPT>: Path to python script.
6 Build your project!
python Build.py <SPECFILE>
<SPECFILE>: Path to the specfile, that have been created in step 4!
The full path to <SPECFILE>:
<UNPACKED_FILES_DIR>/<PYTHON_SCRIPT>/<PYTHON_SCRIPT>.spec
The binary file will be placed in the directory of <SPECFILE>.
If you can restrict your code, then Shed Skin, PyPy, or Cython make true, fast executables.
Py2exe, PyInstaller, or bbfreeze can package Python up to 2.7 into single executables.
Cx_Freeze packages Python up to 3.x into an executable plus many other files.
Yes. Are you making a windowing application or a console application? See the example setup.py files that came with py2exe.