Install VTK for python 3 - python-3.x

I am under OSX (Mojave) and using Python 3.7.0. In order to install a python package to visualise results (Mayavi) I need to install vtk with python 3 bindings.
I have installed python 3.7.0 with brew
I attempted the following:
python3 -m pip install vtk. I get:
Collecting vtk
Could not find a version that satisfies the requirement vtk (from versions: )
No matching distribution found for vtk
brew install vtk --without-python#2does not allow to install the python 3 wrappers
brew install vtk --with-python --without-python#2 gives:
[10%] Built target vtkCommonMath
make: *** [all] Error 2
READ THIS: https://docs.brew.sh/Troubleshooting
I also tried to follow this tutorial but I could not find VTK_WRAP_TCL in the available options of the ccmake. I set the following options:
PYTHON_EXECUTABLE :/usr/local/bin/python3
PYTHON_INCLUDE_DIR: /usr/local/Frameworks/Python.framework/Versions/3.7/include/python3.7m
Compiling VTK goes fine. But when I try to compile the wrappers, the sudo make install gives:
[100%] Built target vtkpython
Install the project...
-- Install configuration: "Debug"
-- Installing: /usr/lib/libvtkCommonCorePython37D-8.2.1.dylib
CMake Error at cmake_install.cmake:36 (file):
file INSTALL cannot copy file "/Users/marco.magliulo/Software/vtkBuild/lib/libvtkCommonCorePython37D-8.2.1.dylib"
to "/usr/lib/libvtkCommonCorePython37D-8.2.1.dylib".
Is there a simple way to get the python 3 wrappers that I did not try ?
Is there something obvious that I am missing in the different attempts I made?

Related

import distutils.command.bdist_wininst as orig

Everything went well while I was trying to create a ros 2 package in Ubuntu 22.04 by following the ros2 documentation, however when I got to the colcon build step, it failed for python packages even though it works for cMake packages.
colcon build --packages-select mypkgpython
...
import distutils.command.bdist_wininst as orig
ModuleNotFoundError: No module named 'distutils.command.bdist_wininst'
knowing that my python version is:
python3 --version
Python 3.10.6
i have tried:
sudo apt-get install python3-distutils:
python3-distutils is already the newest version (3.10.6-1~22.04).
sudo apt-get install python3-apt:
python3-apt is already the newest version (2.4.0).
sudo apt install python3-colcon-common-extensions
python3-colcon-common-extensions is already the newest version(0.3.0-1)
how can i solve this problem?
i expected when i build my python package using
colcon build package
it will be successfully build, so i could work with
The bdist_wininst command was deprecated in Python 3.8 and you are using python 3.10
Its no more found in python3-distutils package .
use
bdist_wheel (wheel packages) instead
or
if you want to run your code as it is downgrade your python to < 3.8
The bdist_wininst format was deprecated in Python 3.8, and the documentation for this format has been removed in Python 3.9. The recommended way to distribute Python packages now is the Wheel format.
you can overcome this error by JUST updating the setuptools
pip install --upgrade setuptools
Note that: Setuptools version 58.2.0 is the last version that works with ROS 2 python packages without any warnings because it is the last version that supports the old installation method, "python setup.py install." This method has been deprecated and replaced by newer, standards-based tools, such as pip and ament.
pip install setuptools==58.2.0

How to install libdoc2testbench on Ubuntu

libdoc2testbench is a tool of Robot Framework which supports importing test results to imbus testbench. Due to Robot Framework documentation, it is to be installed by
pip install robotframework-libdoc2testbench
I want to install it on Ubuntu 18.04; there I get the error:
Could not find a version that satisfies the requirement robotframework-libdoc2testbench (from versions: )
No matching distribution found for robotframework-libdoc2testbench
Best regards
Gerhard
You are probably calling pip from Python 2.7.
Make sure you use Python 3, for example with:
python3 -m pip install robotframework-libdoc2testbench
EDIT: You can download the .wheel or source tar from pypi.org and install with pip pointing to it (and then if needed, download other required packages).
However the solution to your problem is the Python version. From the project page, we see it needs Python 3.7.

Unable to build opencv-python with python 3.8

OS:ubuntu
I am able to install opencv-python from the command line. However,when I tried to install my self-built package with opencv-python dependencies, it failed to biuld:
Building wheels for collected packages: opencv-python
Building wheel for opencv-python (PEP 517): started
Building wheel for opencv-python (PEP 517): finished with status 'error'
ERROR: Complete output from command /usr/local/bin/python /usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /tmp/tmp7jntqv2r:
ERROR: Not searching for unused variables given on the command line.
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
-- Configuring incomplete, errors occurred!
See also "/tmp/pip-install-utbicth7/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
Not searching for unused variables given on the command line.
CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
-- Configuring incomplete, errors occurred!
See also "/tmp/pip-install-utbicth7/opencv-python/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".
-- Trying "Unix Makefiles" generator - failure
--------------------------------------------------------------------------------
********************************************************************************
scikit-build could not get a working generator for your system. Aborting build.
Building Linux wheels for Python 3.6 requires a compiler (e.g gcc).
It can be installed using debian package manager:
sudo apt-get install build-essential
To build compliant wheels, consider using the manylinux system described in PEP-513.
Get it with "dockcross/manylinux-x64" docker image:
https://github.com/dockcross/dockcross#readme
For more details, please refer to scikit-build documentation:
http://scikit-build.readthedocs.io/en/latest/generators.html#linux
********************************************************************************
----------------------------------------
ERROR: Failed building wheel for opencv-python
I suspect issue is with scikit-build. I checked I have ninja, make/gcc all available. I set manually CMAKE_MAKE_PROGRAM=/usr/bin/make.
But still failed with same error. I
You are missing dependencies. Please see this part of the error message you have provided above:
Building Linux wheels for Python 3.6 requires a compiler (e.g gcc).
It can be installed using debian package manager:
sudo apt-get install build-essential
Therefore, please use apt-get to install the build tools required to build your package.
Run pip3 install -U pip before install opencv-python.
Finally figured out, when I installed locally I had a requirements with version 4.1.x and no issues. When I install with the dependencies, it fetches the latest version 4.4 and the issue is that 1) pip version is 19.1 and2) since 4.3 opencv, the wheels has been replaced.

installation of assimulo and sundials - error

I want to use Assimulo and Sundials for the solution of differential algebraic equations in Python and therefore I am trying to install it on Ubuntu.
For the installation of Sundials, I followed the installation instructions and as I understand it worked well.
% cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lib/sundials-3.1.1/ ~/opt/sundials/sundials-3.1.1
% make
% make install
Then I tried to install Assimulo with the command pip3 install Assimulo, but I get an error message. I also tried to follow the instructions on Installation - Assimulo 3.0 documentation by downloading the installation files and install it with the following command. It results in the same error message.
sudo python3 setup.py install --sundials-home=/usr/local/lib/sundials-3.1.1
This is the error message I get:
target build/src.linux-x86_64-3.6/assimulo/thirdparty/hairer/dopri5module.c does not exist:
Assuming dopri5module.c was generated with "build_src --inplace" command.
error: 'assimulo/thirdparty/hairer/dopri5module.c' missing
What is wrong and how can I fix it? Any help would be appreciated!
I got the same error when installing on macos via pip install assimulo, after pip-installing numpy and cython.
For me, using a conda env did the trick:
Creating the conda env: conda create -n your_name_goes_here
conda activate your_name_goes_here
conda install python=3.6 (I noticed you can also use 3.7)
conda install -c conda-forge assimulo
I also had the same error message. As suggested in the other answer, you can get a compiled package from Conda. But if you want to compile from source yourself, it looks to me that PyPI source tarball doesn't contain all needed files. At least some *.pyf files are missing. So, I used SVN repo instead:
svn checkout https://svn.jmodelica.org/assimulo/tags/Assimulo-3.0/ assimulo
By compiling this source tree, I managed to get pass the original error you had, but I'm now having another build error that I don't know yet how to solve:
ssimulo/solvers/sundials.c: In function '__pyx_f_8assimulo_7solvers_8sundials_5CVode_initialize_cvode':
assimulo/solvers/sundials.c:33274:31: error: too many arguments to function 'CVodeCreate'
__pyx_v_self->cvode_mem = CVodeCreate(__pyx_t_3, __pyx_t_4);

Import or Symbol not Found Error with polyglot when PyICU and icu4c installed correctly

I'm really struggling with polyglot, pyicu and icu4c - and it seems like I'm not the only one...
I'm running Mac OS High Sierra 10.13.6 and python3 with a virtualenv
Here are the steps I've taken, largely based on this article:
Start from a new virtualenv
Remove and re-install icu4c (v.62.1) with homebrew
Check ICU_VERSION is "62.1"
Do ln -s /usr/local/Cellar/icu4c/62.1/bin/icu-config /usr/local/bin/icu-config
Download the pyicu tar file (2.1)
Extract pyicu and edit setup.py as indicated in the linked article
build and install pyicu
I see:
Adding CXXFLAGS="-std=c++11 -I/usr/local/Cellar/icu4c/62.1/include" from /usr/local/bin/icu-config
Adding LDFLAGS="-L/usr/local/Cellar/icu4c/62.1/lib -licui18n -licuuc -licudata" from /usr/local/bin/icu-config
Installed/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyICU-2.1-py3.6-macosx-10.6-intel.egg
...
Processing dependencies for PyICU==2.1
Finished processing dependencies for PyICU==2.1
as expected.
pip3 install polyglot
when I run my script I get the following:
File "/Users/Chris/MindWeb/Server/lib/python3.6/site-packages/polyglot/detect/__init__.py", line 1, in <module>
from .base import Detector, Language
File "/Users/Chris/MindWeb/Server/lib/python3.6/site-packages/polyglot/detect/base.py", line 11, in <module>
from icu import Locale
ModuleNotFoundError: No module named 'icu'
Unsurprising because there isn't actually an icu module in PATH.
If, instead of steps 5-7 I do pip3 install pyicu (which creates the icu folder), I get:
ImportError: dlopen(/Users/Chris/MindWeb/Server/lib/python3.6/site-packages/_icu.cpython-36m-darwin.so, 2): Symbol not found: __ZNK6icu_6214Transliterator12getTargetSetERNS_10UnicodeSetE
Referenced from: /Users/Chris/MindWeb/Server/lib/python3.6/site-packages/_icu.cpython-36m-darwin.so
Expected in: flat namespace
in /Users/Chris/MindWeb/Server/lib/python3.6/site-packages/_icu.cpython-36m-darwin.so
output from otool -L /Users/Chris/MindWeb/Server/lib/python3.6/site-packages/_icu.cpython-36m-darwin.so is:
/Users/Chris/MindWeb/Server/lib/python3.6/site-packages/_icu.cpython-36m-darwin.so:
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
This answer on Github was not meant for this error specifically but provides a simple means for installing polyglot using conda and Python 3.6 (after solving the icu error I cam across others so this was helpful).
https://github.com/aboSamoor/polyglot/issues/80#issuecomment-417863726
Using a conda env you do the following:
conda install -c conda-forge pyicu morfessor icu -y && pip install pycld2 polyglot

Resources