How does one solve the character encoding error in PyFMI? - python

I'm on Ubuntu 20.04 trying to load and run an FMU exported from OpenModelica with PyFMI. When I run the code:
from pyfmi import load_fmu
model = load_fmu('Model.fmu')
The following error is produced:
File "src/pyfmi/fmi.pyx", line 7943, in pyfmi.fmi.load_fmu
File "src/pyfmi/fmi.pyx", line 7086, in pyfmi.fmi.FMUModelME2.__init__
File "src/pyfmi/fmi.pyx", line 3761, in pyfmi.fmi.FMUModelBase2.__init__
File "src/pyfmi/fmi.pyx", line 45, in pyfmi.fmi.encode
TypeError: latin_1_encode() argument 1 must be str, not bytes
The result is the same regardless of which I use the version of PyFMI available through pip or conda.
I've spent hours trying to find a solution, but to no avail. On pip, he package information returned from pyfmi.check_packages() is:
PyFMI version ................ 2.5
Platform ..................... linux
Python version ............... 3.8.5
Dependencies:
Package Version
------- -------
assimulo...................... 3.0
Cython........................ 0.29.22
lxml.......................... 4.5.0
matplotlib.................... 3.1.2
numpy......................... 1.17.4
scipy......................... 1.6.1
and on conda it's
PyFMI version ................ 2.5
Platform ..................... linux
Python version ............... 3.8.5
Dependencies:
Package Version
------- -------
assimulo...................... 3.0
Cython........................ 0.29.22
lxml.......................... 4.6.2
matplotlib.................... 3.3.4
numpy......................... 1.20.1
scipy......................... 1.6.1
Note: I've tried install version PyFMI 2.8.5 via conda, but I always seem to end up with 2.5 regardless of what I try.
Does anyone have any suggestions? Many thanks for any help!

I realise now why the wrong version of the package was being loaded. After uninstalling the pip version (2.5) the conda version (2.8.5) became visible, see below (updated after fixing second issue). Of course, now I have a different problem, but I'll document that in a different thread... it turned out to be a similar issue. I had an outdated Assimulo package installed in pip, which when uninstalled, allowed the conda version to be used correctly. I'm leaving the record of my solution visible in the hope that someone else in my position might benefit from it.
Performing pyfmi package check
==============================
PyFMI version ................ 2.8.5
Platform ..................... linux
Python version ............... 3.8.5
Dependencies:
Package Version
------- -------
assimulo...................... 3.2.3
Cython........................ 0.29.22
lxml.......................... 4.6.2
matplotlib.................... 3.3.4
numpy......................... 1.20.1
scipy......................... 1.6.1

Related

Error:The conflict is caused by: Spleeter 2.3.0 depends on tensorflow==2.5.0 Spleeter 2.1.0 depends on tensorflow==2.3.0 on Raspberry pi3 3

I am trying to write a bash script on a Raspberrypi 3B that includes the library 'Spleeter'.
I tried pip install spleeter but got the following error:
The conflict is caused by: Spleeter 2.3.0 depends on tensorflow==2.5.0 Spleeter 2.1.0 depends on tensorflow==2.3.0
and got the following additional message:
`To fix this you could try to: 1.Loosen the range of package version you've specified 2.Remove package versions to allow pip attempt to solve the dependency conflict`
I am not sure how to go about this. I tried to go for an older version of the package but the installation halts midway. I tried installing an older version of python as well. I was not successful. Any and all inputs/support are appreciated.

ERROR: (wheel).whl is not a supported wheel on this platform

I'm trying to build Tensorflow from source (if I install directly it works fine but I'm trying to get AVX2/FMA extensions support as I can't use CUDA/GPU) and I'm following this tutorial to build Tensorflow 1.15 (which is needed for the project that I use, I can't use 2.x).
I've built Tensorflow successfully, but when I try to install the wheel with pip I get the following error:
ERROR: tensorflow-1.15.5-cp37-cp37m-macosx_11_0_x86_64.whl is not a supported wheel on this platform.
Well, I know what the error means but the problem is that:
The wheel, as implied by the filename, is built for:
Python 3.7
macOS 11.0
x86/64
Which is already what I have (yup, double checked Python version, it's exactly Python 3.7.9, and no I'm not on M1 if that matters, I'm on Intel Mac). Why am I getting this error message even though I'm on the platform that the wheel is built for?
UPDATE: I'm already on the latest pip as of writing, and I can verify pip and python point to the same version:
(tf) can#can-mbp tensorflow % which pip
/opt/anaconda3/envs/tf/bin/pip
(tf) can#can-mbp tensorflow % which python
/opt/anaconda3/envs/tf/bin/python
(tf) can#can-mbp tensorflow % pip -V
pip 21.0 from /opt/anaconda3/envs/tf/lib/python3.7/site-packages/pip (python 3.7)
(tf) can#can-mbp tensorflow % python -V
Python 3.7.9
FOR MACOS - BIG SUR
I was able to solve this problem when I found that the version of the macOS operating system does not match the version actually recognized by python
I'm using macOS 11.4, the file is with this version. But when typing a command in the terminal, I found that python recognizes 11.0.
python3
from distutils import util
util.get_platform()
>> 'macosx-11.0-arm64'
generated file name:
opencv_python-4.5.2+2344814-cp39-cp39-macosx_11_4_arm64.whl
new file name:
opencv_python-4.5.2+2344814-cp39-cp39-macosx_11_0_arm64.whl
Upon #Axe319's comment I took a look at https://github.com/apple/tensorflow_macos/issues/46 and seen that simply changing the wheel's filename's OS section to 10_9 works. There is probably a bug with parsing macOS 11.0 or Python doesn't think it supports 11.0 (maybe that particular Python/pip version was before Big Sur was released).
Make sure the Python version you are using (32/64 bit) does match what the wheel requires ;)

Tensorflow installing error: __ is not a supported wheel on this platform

I'm trying to install tensorflow on my PC but I keep getting errors.
I have seen multiple posts about tensorflow installing errors online but all I found was solutions saying that the version of python was not compatible. However, I am using python 3.8 and I am using the URL for python 3.8 provided on tensorflow's website, so I don't see how that could be the issue.
The command I'm using:
python -m pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.2.0-cp38-cp38-win_amd64.whl
The error I'm getting:
ERROR: tensorflow_cpu-2.2.0-cp38-cp38-win_amd64.whl is not a supported wheel on this platform.
I'm using python 3.8, pip 20.1.1 and my PC is running 64 bit Windows 10.
From tensorflow's website, the requirements are :
Python 3.5-3.8
pip 19.0 or later
Windows 7 or later
Which are all satisfied.
Why am I getting this error?
EDIT: using only pip install tensorflow gets me the following errors:
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
ERROR: No matching distribution found for tensorflow
It's likely you're using the 32bit version of python 3.8 instead of the 64bit version. You can check by opening the interpreter and looking at the first line. If it has 32 bit (Intel) or something similar, then it would be the 32 bit version. To get the 64bit edition, scroll down to Files on this link https://www.python.org/downloads/release/python-380/ and pick up the x86-64 version.

Autokeras installation with Anaconda

I have problems with installing Autokeras with Anaconda.
I downgraded python to 3.6
I installed pytorch and downgraded to
version 0.4.1
I downgraded numpy to 1.14.5
I installed visual studio C++ build tool
But now I get the error that tensorflow will require max numpy version 1.14.5. but autokeras will upgrade numpy to 1.15.4 and it failed to build the wheel for lws
After every step ther was an error.
Is there a simple, straight forward way to install Autokeras on Annaconda (Win)?
Thanks for your help
I have Windows 10, Anaconda 2019.10 and Python 3.7.5. In my case, I get the error ERROR: No matching distribution found for torch==1.0.1.post2 (from autokeras) on Windows 10 when trying to pip install autokeras as indicated by the official documentation.
Then I try to get the source code from https://github.com/keras-team/autokeras and run python setup.py install. It successfully installs autokeras for me.
I had the same issues, using Windows 10 Pro. I installed VMware Workstation 15 Player, installed lubuntu as the guest OS, installed anaconda onto that, created a conda virtual environment, and was able to install autokeras as per https://autokeras.com/start/ . The autokeras installation gave a numpy version error, but seems to work. This might not be the answer you are looking for.
Another answer you might not be looking for is to use Docker, as per https://autokeras.com/docker/ . Once I'd changed "$(pwd)":/app to "$(pwd):/app" in the example, this also seems to work.

How to install pytables 3.2 on anaconda?

I use anaconda, and I cannot upgrade with
conda update pytables
it says "already installed".
....
# All requested packages already installed.
# packages in environment at C:\Anaconda:
#
pytables 3.1.1 np19py27_1
Then I tried pip:
C:\Users\HP>pip install --upgrade tables
Collecting tables
Using cached tables-3.2.0.tar.gz
Complete output from command python setup.py egg_info:
H5closecfvx_f.c
r:\temp\H5closecfvx_f.c(2) : warning C4013: 'H5close' undefined; assuming ex
tern returning int
LINK : fatal error LNK1181: cannot open input file 'hdf5dll.lib'
* Using Python 2.7.3 |Anaconda 2.2.0 (32-bit)| (default, Feb 25 2013, 18:26:
30) [MSC v.1500 32 bit (Intel)]
* USE_PKGCONFIG: False
.. ERROR:: Could not find a local HDF5 installation.
You may need to explicitly state where your local HDF5 headers and
library can be found by setting the ``HDF5_DIR`` environment
variable or by using the ``--hdf5`` command-line option.
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in r:\temp\pip-build
-rxtig1\tables
I searched my hard disk, and couldn't find hdf5dll.lib file.
Then I downloaded the latest HDF5-1.8.15 Patch1 and point HDF5_DIR to the installed directory, still same error, and there's no hdf5dll.lib file in the newly installed HDF5 directory either.
EDIT: Since the PR below was merged, pytables is available with
conda install -c conda-forge pytables
Also, this package is available in the defaults channel, but only for numpy 1.11.
pip is a pretty difficult way to line these up. A better approach is probably to build a pytables package. One effort to do so is at https://github.com/conda-forge/staged-recipes/pull/1134
Conda packaging makes it much easier to line up all the library dependencies. It essentially allows the burden of build to be centralized, so that not everyone who installs something needs to know how to build it.
Conda forge is a community effort to collaboratively package our ecosystem.

Categories