Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type Error using CoolProp 6.6.0 on Raspberry Pi4, python 3.9 #2340

Open
hatfieldr opened this issue Dec 27, 2023 · 14 comments
Open

Type Error using CoolProp 6.6.0 on Raspberry Pi4, python 3.9 #2340

hatfieldr opened this issue Dec 27, 2023 · 14 comments

Comments

@hatfieldr
Copy link

hatfieldr commented Dec 27, 2023

Raspberry Pi 4 running Buster
Python 3.9.2
Cython 3.0.6
CoolProp 6.6.0

I originally installed CoolProp via pip:

pip install CoolProp

There were no obvious problems with the installation but as I had an error trying to import it I did a manual install:

git clone https://github.com/CoolProp/CoolProp --recursive

cd CoolProp/wrappers/Python

sudo python setup.py install

Again there were no installation errors but on trying to import the module I get a type error:

Traceback (most recent call last):
  File "/home/richard/python_code/hydrogen_density1.py", line 1, in <module>
    import CoolProp.CoolProp as CP
  File "/home/richard/.local/lib/python3.9/site-packages/CoolProp/__init__.py", line 22, in <module>
    __fluids__ = CoolProp.get_global_param_string('fluids_list').split(',')
  File "CoolProp.pyx", line 309, in CoolProp.CoolProp.get_global_param_string
  File "<stringsource>", line 15, in string.from_py.__pyx_convert_string_from_py_std__in_string
TypeError: expected bytes, str found

I have seen a similar problem described by others but I cant find a solution. I have not tried degrading python to say 3.8 , as I have many other python packages that are working fine and would be affected.

Help would be greatly appreciated!

@ibell
Copy link
Contributor

ibell commented Dec 28, 2023

I tried to use the Raspbery PI for Desktop ISO, and I was able to get it booting in VirtualBox (eventually). I built and used the wheel and it worked flawlessly. I did:

image

The pip line is probably not necessary (there is an issue with old python versions).

So the issue might be with the arm64 version of python, which would make no sense to me, since the macs also use arm64, and that works fine too. There can be issues with wide unicode builds, but I don't understand why only on raspberry pi it is expected that the function takes bytes, and on all other platforms the argument is expected to be a string.

@ibell
Copy link
Contributor

ibell commented Dec 28, 2023

For future readers: make sure you turn the number of CPU to >1 in virtualbox. Otherwise you get kernel panics, I think this is the reason for this problem I had: https://forums.virtualbox.org/viewtopic.php?t=105926 . Mount the ISO, but don't use the ISO as the image.

@ibell
Copy link
Contributor

ibell commented Dec 28, 2023

@ibell
Copy link
Contributor

ibell commented Dec 28, 2023

I have the qemu up and running with the link from above, but it is SLOW(!!). I bit the bullet and have a Raspberry Pi headed my way in a few days. Hopefully I can get to the bottom of this issue.

@ibell
Copy link
Contributor

ibell commented Dec 28, 2023

Access to a Pi seems to be needed. There is something odd with the python that is unlike all other platforms and emulation is not viable since the problem cannot be reproduced with non-arm builds.

@hatfieldr
Copy link
Author

hatfieldr commented Jan 1, 2024

Dear Ian
Thank you for your comments, apologies for the delay in getting back
I tried your suggestion and the wheel seemed to build ok but I was unable to install it, it was not recognised:

richard@raspberrypi:/CoolProp/wrappers/Python $ cd dist
richard@raspberrypi:
/CoolProp/wrappers/Python/dist $ ls
CoolProp-6.6.1.dev0-cp39-cp39-linux_aarch64.whl
CoolProp-6.6.1.dev0-py3.9-linux-aarch64.egg
richard@raspberrypi:~/CoolProp/wrappers/Python/dist $ pip install CoolProp-6.6.1.dev0-cp39-cp39-linux_aarch64.whl
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
ERROR: CoolProp-6.6.1.dev0-cp39-cp39-linux_aarch64.whl is not a supported wheel on this platform.

I did check that my Buster was 64 bit:
richard@raspberrypi:~/CoolProp/wrappers/Python/dist $ uname -m
aarch64

I appreciate your time and the fact that you have a Pi4 on the way!
Do you have any other suggestions at this stage?

Richard

@ibell
Copy link
Contributor

ibell commented Jan 2, 2024 via email

@ibell
Copy link
Contributor

ibell commented Jan 3, 2024

Some good news and bad news. I got my pi, set it up, I'm at:

belli@raspberrypi:~/Desktop $ python
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

and it worked just fine. I did:

git clone --recursive --shallow-submodules https://github.com/coolprop/coolprop
cd coolprop/wrappers/Python
python setup.py bdist_wheel

then I set up a virtual env with python -m venv . and used

belli@raspberrypi:~/coolprop/wrappers/Python $ bin/pip install dist/CoolProp-6.6.1.dev0-cp311-cp311-linux_aarch64.whl
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Processing ./dist/CoolProp-6.6.1.dev0-cp311-cp311-linux_aarch64.whl
Installing collected packages: CoolProp
Successfully installed CoolProp-6.6.1.dev0
belli@raspberrypi:~/coolprop/wrappers/Python $ bin/python
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
belli@raspberrypi:~/coolprop/wrappers $ Python/bin/python
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import CoolProp
>>>

so my next guess is that there is a bug bug in the Raspberry Pi version of Python, that was fixed in the version I have. Can you update your python to 3.11 and try again? Otherwise I can I think make a virtual env with an older version of python.

@wandadars
Copy link
Contributor

Just want to pop in here and give Ian an award for buying a Raspberry PI just to squash a bug.

@ibell
Copy link
Contributor

ibell commented Jan 4, 2024

I think buster might be the problem. I cannot replicate the error on either bullseye or bookworm. In fact, on modern raspberry pi OS, you can use the binary wheels, which is awesome.

@ibell
Copy link
Contributor

ibell commented Jan 4, 2024

Just want to pop in here and give Ian an award for buying a Raspberry PI just to squash a bug.

My pleasure !

@hatfieldr
Copy link
Author

Ian
Thank you so much for your help.
I did a fresh install of Raspbian OS 12 "Bookworm" which comes with Python 3.11.2
I installed Cython 3.0.7
I had a few hiccups building the wheel - the Pi froze twice with no error messages but a simple pip install CoolProp worked fine installing CooProp 6.6.0
It now imports fine with no error messages! Now I just have to get all the other packages installed and working!
I guess the problem was with Buster / Python 3.9

The new install I tried on a spare Pi4 at home. The main Pi I am working with I only, currently, have remote access to via SSH and Real VNC. It is setup in an Argon case with a built-in SSD and is being used as a controller for a small scale hydrogen filling station - it has a fair number of inputs and outputs and a number of python libraries which need to be stable! There is a limit as to how much I can do remotely.
Hydrogen has some nasty non ideal properties and I was trying to keep track of its density with varying temperature and pressure. CoolProp makes this problem really easy!

Thanks for your help

@ibell
Copy link
Contributor

ibell commented Jan 4, 2024

@hatfieldr This project sounds so cool! Impressed a Pi is enough to drive your filling station. Do you have further information on this project somewhere?

I am glad to hear that you were able to get things working with bookworm. I fear there is nothing that can be done in buster to fix things, I think you might have to rebuild your main Pi if you want to work with CoolProp in your application.

@vespadj
Copy link

vespadj commented Jan 16, 2024

I also update from Buster to Bookworm link.
On Bookwork I finally active again RealVNC (deprecaded by Raspberry).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants