Slycot fails to import when using control - python-3.x

I cannot seem to get the control.ss2tf() function to work for state space MIMO system. The function works perfectly for a SISO system.
The following code is used to run the module:
control.ss2tf(A,B,C,D)
The resulting output indicated that the slycot module was not installed.
I then tried installing slycot with
pip install slycot
This command gave the following output:
Failed building wheel for slycot
Running setup.py clean for slycot
Failed to build slycot
Installing collected packages: slycot
Running setup.py install for slycot ... error
Complete output from command c:\users\wian\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Wian\\AppData\\Local\\Temp\\pip-install-cmcxwtts\\slycot\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Wian\AppData\Local\Temp\pip-record-_n6gj2yv\install-record.txt --single-version-externally-managed --compile:
Running from numpy source directory.
running install
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building py_modules sources
building extension "slycot._wrapper" sources
f2py options: []
adding 'build\src.win-amd64-3.6\build\src.win-amd64-3.6\slycot\src\fortranobject.c' to sources.
adding 'build\src.win-amd64-3.6\build\src.win-amd64-3.6\slycot\src' to include_dirs.
adding 'build\src.win-amd64-3.6\slycot\src\_wrapper-f2pywrappers.f' to sources.
build_src: building npy-pkg config files
running build_py
copying slycot\version.py -> build\lib.win-amd64-3.6\slycot
copying build\src.win-amd64-3.6\slycot\__config__.py -> build\lib.win-amd64-3.6\slycot
running build_ext
Looking for python36.dll
Building import library (arch=AMD64): "c:\users\wian\anaconda3\libs\libpython36.a" (from c:\users\wian\anaconda3\python36.dll)
objdump.exe: c:\users\wian\anaconda3\python36.dll: file format not recognized
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\Wian\AppData\Local\Temp\pip-install-cmcxwtts\slycot\setup.py", line 241, in <module>
setup_package()
File "C:\Users\Wian\AppData\Local\Temp\pip-install-cmcxwtts\slycot\setup.py", line 233, in setup_package
setup(**metadata)
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\core.py", line 171, in setup
return old_setup(**new_attr)
File "c:\users\wian\anaconda3\lib\site-packages\setuptools\__init__.py", line 145, in setup
return distutils.core.setup(**attrs)
File "c:\users\wian\anaconda3\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "c:\users\wian\anaconda3\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "c:\users\wian\anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\command\install.py", line 62, in run
r = self.setuptools_run()
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\command\install.py", line 36, in setuptools_run
return distutils_install.run(self)
File "c:\users\wian\anaconda3\lib\distutils\command\install.py", line 545, in run
self.run_command('build')
File "c:\users\wian\anaconda3\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "c:\users\wian\anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\command\build.py", line 47, in run
old_build.run(self)
File "c:\users\wian\anaconda3\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "c:\users\wian\anaconda3\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "c:\users\wian\anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\command\build_ext.py", line 116, in run
force=self.force)
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\ccompiler.py", line 765, in new_compiler
compiler = klass(None, dry_run, force)
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 103, in __init__
build_import_library()
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 415, in build_import_library
return _build_import_library_amd64()
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 471, in _build_import_library_amd64
generate_def(dll_file, def_file)
File "c:\users\wian\anaconda3\lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 301, in generate_def
raise ValueError("Symbol table not found")
ValueError: Symbol table not found
I read that this is due to a FORTRAN compiler not installed on the system. I therefore installed gfortran with Ming32. To verify the install I ran the following:
(base) C:\WINDOWS\system32>gfortran
gfortran: fatal error: no input files
compilation terminated.
So gfortran is installed as a compiler, but yet pip remain unable to install slycot. I have also installed Microsoft Visual Studio 2017.
At this point I went to PyPi library to download the compiled binary of the slycot module. https://www.lfd.uci.edu/~gohlke/pythonlibs/
Here I downloaded the correct .whl file for my system (64 bit Python 3.6), and installed it with pip.
pip install "C:\Users\Wian\Desktop\slycot-0.3.3-cp36-cp36m-win_amd64.whl"
Using this command slycot 0.3.3 was installed successfully. However, when i run the command
control.ss2tf(A,B,C,D)
I get the following output
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\control\xferfcn.py in _convertToTransferFunction(sys, **kw)
1089 try:
-> 1090 from slycot import tb04ad
1091 if len(kw):
ImportError: cannot import name 'tb04ad'
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
<ipython-input-8-2b014ac15956> in <module>()
----> 1 control.ss2tf(Model)
~\Anaconda3\lib\site-packages\control\xferfcn.py in ss2tf(*args)
1315 sys = args[0]
1316 if isinstance(sys, StateSpace):
-> 1317 return _convertToTransferFunction(sys)
1318 else:
1319 raise TypeError("ss2tf(sys): sys must be a StateSpace object. It \
~\Anaconda3\lib\site-packages\control\xferfcn.py in _convertToTransferFunction(sys, **kw)
1113 # If slycot is not available, use signal.lti (SISO only)
1114 if (sys.inputs != 1 or sys.outputs != 1):
-> 1115 raise TypeError("No support for MIMO without slycot")
1116
1117 # Do the conversion using sp.signal.ss2tf
TypeError: No support for MIMO without slycot
When I try to import slycot in Python, I get the following result:
>>> import slycot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Wian\Anaconda3\lib\site-packages\slycot\__init__.py", line 18, in <module>
from .analysis import ab01nd,ab05md,ab05nd,ab07nd,ab08nd, \
File "C:\Users\Wian\Anaconda3\lib\site-packages\slycot\analysis.py", line 21, in <module>
from . import _wrapper
ImportError: DLL load failed: The specified module could not be found.
There is a _wrapper.pyd file in the Slycot directory (under Anaconda3\Libs\site-packages).
This is where I am currently stuck, and I cannot get Slycot to import correctly.
Your help is greatly appreciated!

Related

OSError: Python library not found: libpython3.7.so.1.0, libpython3.7m.so.1.0

I am using pyinstaller on CentOS 7 to convert a .py file to an executable. I am on python3.7.6
I have done:
$python3.7 -m pip install pyinstaller
$pyinstaller test.py --onefile
This gives me:
8942 INFO: Python library not in binary dependencies. Doing additional searching...
Traceback (most recent call last):
File "/usr/local/bin/pyinstaller", line 8, in <module>
sys.exit(run())
File "/usr/local/lib/python3.7/site-packages/PyInstaller/__main__.py", line 126, in run
run_build(pyi_config, spec_file, **vars(args))
File "/usr/local/lib/python3.7/site-packages/PyInstaller/__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 815, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 762, in build
exec(code, spec_namespace)
File "/root/test.spec", line 19, in <module>
noarchive=False)
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 294, in __init__
self.__postinit__()
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/datastruct.py", line 159, in __postinit__
self.assemble()
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 540, in assemble
self._check_python_library(self.binaries)
File "/usr/local/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 645, in _check_python_library
python_lib = bindepend.get_python_library_path()
File "/usr/local/lib/python3.7/site-packages/PyInstaller/depend/bindepend.py", line 967, in get_python_library_path
raise IOError(msg)
OSError: Python library not found: libpython3.7.so, libpython3.7.so.1.0, libpython3.7mu.so.1.0, libpython3.7m.so, libpython3.7m.so.1.0
This would mean your Python installation doesn't come with proper library files.
This usually happens by missing development package, or unsuitable build parameters of Python installation.
* On Debian/Ubuntu, you would need to install Python development packages
* apt-get install python3-dev
* apt-get install python-dev
* If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)
As pointed out here I have tried:
$env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.7.6
I have also installed python-devel:
$yum install python36-gobject-devel.x86_64
$yum install python3-devel.x86_64
$yum install python34-devel.x86_64
I am not sure what am I missing here. Any help will be appreciated.

How to solve the metadata wheel error during installation of pyqt5 with pip

I recently installed a virtual environement using pyvenv in Python and it worked fine until I needed to install PyQt5.
After that I also tried installing directly but it gave me other problems too related to SIP
My operating system is Ubuntu 14.04 32 bit,
I ran:
sudo -H python3 -m pip install pyqt5
The output was:
Collecting pyqt5
Using cached PyQt5-5.15.0.tar.gz (3.3 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... error
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python3 /usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpkqu84tmx
cwd: /tmp/pip-install-d7z8r80t/pyqt5
Complete output (35 lines):
Querying qmake about your Qt installation...
/usr/bin/qmake -query
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 126, in prepare_metadata_for_build_wheel
hook = backend.prepare_metadata_for_build_wheel
AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 280, in <module>
main()
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 263, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 131, in prepare_metadata_for_build_wheel
config_settings)
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py", line 159, in _get_wheel_metadata_from_wheel
whl_basename = backend.build_wheel(metadata_directory, config_settings)
File "/tmp/pip-build-env-pn13k50g/overlay/lib/python3.6/site-packages/sipbuild/api.py", line 51, in build_wheel
project = AbstractProject.bootstrap('pep517')
File "/tmp/pip-build-env-pn13k50g/overlay/lib/python3.6/site-packages/sipbuild/abstract_project.py", line 82, in bootstrap
project.setup(pyproject, tool, tool_description)
File "/tmp/pip-build-env-pn13k50g/overlay/lib/python3.6/site-packages/sipbuild/project.py", line 477, in setup
self.apply_user_defaults(tool)
File "project.py", line 62, in apply_user_defaults
super().apply_user_defaults(tool)
File "/tmp/pip-build-env-pn13k50g/overlay/lib/python3.6/site-packages/pyqtbuild/project.py", line 86, in apply_user_defaults
super().apply_user_defaults(tool)
File "/tmp/pip-build-env-pn13k50g/overlay/lib/python3.6/site-packages/sipbuild/project.py", line 223, in apply_user_defaults
self.builder.apply_user_defaults(tool)
File "/tmp/pip-build-env-pn13k50g/overlay/lib/python3.6/site-packages/pyqtbuild/builder.py", line 76, in apply_user_defaults
self._get_qt_configuration()
File "/tmp/pip-build-env-pn13k50g/overlay/lib/python3.6/site-packages/pyqtbuild/builder.py", line 445, in _get_qt_configuration
"v{0}".format(self.qt_version_str))
sipbuild.exceptions.UserException
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python3 /usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpkqu84tmx Check the logs for full command output.

I tried to build app with buildozer kivy, but i have an error

I am trying to make android app using kivy.
I downloaded kivy buildozer VM setup and did steps from here
but I get this error:
# Cwd /home/kivy/Desktop/ekek/.buildozer/android/platform/python-for-android
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/kivy/Desktop/ekek/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 96, in <module>
from pythonforandroid.distribution import Distribution, pretty_log_dists
File "pythonforandroid/distribution.py", line 48
*,
^
SyntaxError: invalid syntax
# Command failed: /usr/bin/python -m pythonforandroid.toolchain create --dist_name=myapp --bootstrap=sdl2 --requirements=python3,kivy --arch armeabi-v7a --copy-libs --color=always --storage-dir="/home/kivy/Desktop/ekek/.buildozer/android/platform/build-armeabi-v7a" --ndk-api=21
#
I have tried changing python3 in buidozer spec file to python 2 but i didn't change anything.
I still have this error.

How to install scipy with pip3?

I got the following error when I try to install scipy with pip3 on Mac OS X 10.14.1. Does anybody know what the problem is? I was able to install scipy with pip2.
$ pip3 install scipy
Collecting scipy
Using cached https://files.pythonhosted.org/packages/ee/5b/5afcd1c46f97b3c2ac3489dbc95d6ca28eacf8e3634e51f495da68d97f0f/scipy-1.3.1.tar.gz
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... error
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/mktemp/tmp9rjyv64p
cwd: /private/tmp/mktemp/pip-install-w63x23dy/scipy
Complete output (50 lines):
setup.py:386: UserWarning: Unrecognized setuptools command ('dist_info --egg-base /private/tmp/mktemp/pip-install-w63x23dy/scipy/pip-wheel-metadata'), proceeding with generating Cython sources and expanding templates
warnings.warn("Unrecognized setuptools command ('{}'), proceeding with "
Traceback (most recent call last):
File "/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/core/__init__.py", line 16, in <module>
from . import multiarray
ImportError: dlopen(/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/core/multiarray.cpython-38m-darwin.so, 2): Symbol not found: _aheapsort_bool
Referenced from: /private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/core/multiarray.cpython-38m-darwin.so
Expected in: flat namespace
in /private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/core/multiarray.cpython-38m-darwin.so
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
main()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 69, in prepare_metadata_for_build_wheel
return hook(metadata_directory, config_settings)
File "/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 156, in prepare_metadata_for_build_wheel
self.run_setup()
File "/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 236, in run_setup
super(_BuildMetaLegacyBackend,
File "/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 142, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 505, in <module>
setup_package()
File "setup.py", line 481, in setup_package
from numpy.distutils.core import setup
File "/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/core/__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: dlopen(/private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/core/multiarray.cpython-38m-darwin.so, 2): Symbol not found: _aheapsort_bool
Referenced from: /private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/core/multiarray.cpython-38m-darwin.so
Expected in: flat namespace
in /private/tmp/mktemp/pip-build-env-4kdqsfzb/overlay/lib/python3.8/site-packages/numpy/core/multiarray.cpython-38m-darwin.so
----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/mktemp/tmp9rjyv64p Check the logs for full command output.
WARNING: You are using pip version 19.2.2, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

how can i fix this invalid ELF header errror?

I installed zeromq on ubuntu 10.04 and the compilation went through without any errors.
However when i try to run the python test, it results in this error:
jerome#VM1:~/zeromq/pyzmq-2.0.7$ python setup.py test
running test
Traceback (most recent call last):
File "setup.py", line 144, in <module>
'Topic :: System :: Networking'
File "/usr/lib/python2.6/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib/python2.6/distutils/dist.py", line 975, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.6/distutils/dist.py", line 995, in run_command
cmd_obj.run()
File "setup.py", line 59, in run
tests = TestLoader().loadTestsFromNames(testfiles)
File "/usr/lib/python2.6/unittest.py", line 613, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/usr/lib/python2.6/unittest.py", line 576, in loadTestsFromName
module = __import__('.'.join(parts_copy))
File "/home/jerome/zeromq/pyzmq-2.0.7/zmq/__init__.py", line 26, in <module>
from zmq import _zmq
ImportError: /home/jerome/zeromq/pyzmq-2.0.7/zmq/_zmq.so: invalid ELF header
What do i need to do to fix this?
Try setting up pyzmq like this:
python setup.py configure --zmq=<your_zmqlibrary_installation_path>
python setup.py build_ext --rpath=<your_zmqlibrary_installation_path>/lib --inplace
python setup.py install
python setup.py test
According to how can i fix this invalid ELF header errror? you need to compile zeromq on your target instead of using a MAC OS X version ...

Resources