Tuckie / max31855

Raspberry Pi driver for MAX31855 Cold-Junction Compensated Thermocouple-to-Digital Converter
MIT License
53 stars 30 forks source link

Installing max31855 in python 3 #10

Open Yobeco opened 5 years ago

Yobeco commented 5 years ago

Hi

I'm trying to install your max31855's module to use two "k thermocouples" on a Raspberry pi 3 under Raspbian 10.0. The installation seems to be ok... When I call it in Python 3 :

>>> import max31855
>>>

I don't have any error message.

Here is the python script that I use to check the sensor :

   # from max31855 import MAX31855, MAX31855Error
    import max31855

    cs_pin=24
    clock_pin=23
    data_pin=22
    unit="f"
    thermocouple1=MAX31855(cs_pin, clock_pin, data_pin, units)
    print(thermocouple.get())
    thermocouple.cleanup()

Any time, I have the same message error :

Traceback (most recent call last):
  File "Essai_MAX31855_V1.py", line 8, in <module>
    thermocouple1=MAX31855(cs_pin, clock_pin, data_pin, units)
NameError: name 'MAX31855' is not defined

Do you have any idea ?

Thank you :-)

Tuckie commented 5 years ago

Could you try uncommenting the first line?

from:

# from max31855 import MAX31855, MAX31855Error

to this:

from max31855 import MAX31855, MAX31855Error
Yobeco commented 5 years ago

Ok I did it. But I did it on a new installation of Raspbian on my Raspberry Pi 3. First, I activate "SSH", "VNC", "SPI" and "Remote GPIO".

Here is alI I did on my full clear new installation of Raspbian:

1- New installation of Raspbian on a Rpi3

pi@raspberrypi:~/Python/Essais_MAX31855 $ uname -a
Linux raspberrypi 4.19.58-v7+ #1245 SMP Fri Jul 12 17:25:51 BST 2019 armv7l GNU/Linux
pi@raspberrypi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:    10
Codename:   buster
pi@raspberrypi:~ $ 

2- Installation of the module

pi@raspberrypi:~ $ git clone https://github.com/Tuckie/max31855

Clonage dans 'max31855'...
remote: Enumerating objects: 33, done.
remote: Total 33 (delta 0), reused 0 (delta 0), pack-reused 33
Dépaquetage des objets: 100% (33/33), fait.

pi@raspberrypi:~ $ cd max31855/
pi@raspberrypi:~/max31855 $ sudo python3 setup.py install
running install
running bdist_egg
running egg_info
creating max31855.egg-info
writing max31855.egg-info/PKG-INFO
writing dependency_links to max31855.egg-info/dependency_links.txt
writing top-level names to max31855.egg-info/top_level.txt
writing manifest file 'max31855.egg-info/SOURCES.txt'
reading manifest file 'max31855.egg-info/SOURCES.txt'
writing manifest file 'max31855.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-armv7l/egg
running install_lib
warning: install_lib: 'build/lib' does not exist -- no Python modules to install

creating build
creating build/bdist.linux-armv7l
creating build/bdist.linux-armv7l/egg
creating build/bdist.linux-armv7l/egg/EGG-INFO
copying max31855.egg-info/PKG-INFO -> build/bdist.linux-armv7l/egg/EGG-INFO
copying max31855.egg-info/SOURCES.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying max31855.egg-info/dependency_links.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying max31855.egg-info/top_level.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/max31855-2.0-py3.7.egg' and adding 'build/bdist.linux-armv7l/egg' to it
removing 'build/bdist.linux-armv7l/egg' (and everything under it)
Processing max31855-2.0-py3.7.egg
Copying max31855-2.0-py3.7.egg to /usr/local/lib/python3.7/dist-packages
Adding max31855 2.0 to easy-install.pth file

Installed /usr/local/lib/python3.7/dist-packages/max31855-2.0-py3.7.egg
Processing dependencies for max31855==2.0
Finished processing dependencies for max31855==2.0

3- Checking of the module

pi@raspberrypi:~/max31855 $ python3
Python 3.7.3 (default, Apr  3 2019, 05:39:12) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import max31855
>>>
>>> exit()

4- Running the test script

pi@raspberrypi:~/max31855 $ cd /home/pi/Python/Essais_MAX31855/
pi@raspberrypi:~/Python/Essais_MAX31855 $ python3 Essai_MAX31855_V1.py 
Traceback (most recent call last):
  File "Essai_MAX31855_V1.py", line 1, in <module>
    from max31855 import MAX31855, MAX31855Error

_The code of "Essai_MAX31855V1.py":

from max31855 import MAX31855, MAX31855Error

cs_pin=24
clock_pin=23
data_pin=22
unit="f"
thermocouple1=MAX31855(cs_pin, clock_pin, data_pin, units)
print(thermocouple.get())
thermocouple.cleanup()

5- New installation of the module in the folder of the test script

pi@raspberrypi:~/max31855 $ cd /home/pi/Python/Essais_MAX31855/
pi@raspberrypi:~/Python/Essais_MAX31855 $ git clone https://github.com/Tuckie/max31855
Clonage dans 'max31855'...

remote: Enumerating objects: 33, done.
remote: Total 33 (delta 0), reused 0 (delta 0), pack-reused 33
Dépaquetage des objets: 100% (33/33), fait.
pi@raspberrypi:~/Python/Essais_MAX31855 $ 

pi@raspberrypi:~/Python/Essais_MAX31855 $ cd max31855/
pi@raspberrypi:~/Python/Essais_MAX31855/max31855 $ sudo python3 setup.py install
running install
running bdist_egg
running egg_info
creating max31855.egg-info
writing max31855.egg-info/PKG-INFO
writing dependency_links to max31855.egg-info/dependency_links.txt
writing top-level names to max31855.egg-info/top_level.txt
writing manifest file 'max31855.egg-info/SOURCES.txt'
reading manifest file 'max31855.egg-info/SOURCES.txt'
writing manifest file 'max31855.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-armv7l/egg
running install_lib
warning: install_lib: 'build/lib' does not exist -- no Python modules to install

creating build
creating build/bdist.linux-armv7l
creating build/bdist.linux-armv7l/egg
creating build/bdist.linux-armv7l/egg/EGG-INFO
copying max31855.egg-info/PKG-INFO -> build/bdist.linux-armv7l/egg/EGG-INFO
copying max31855.egg-info/SOURCES.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying max31855.egg-info/dependency_links.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying max31855.egg-info/top_level.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/max31855-2.0-py3.7.egg' and adding 'build/bdist.linux-armv7l/egg' to it
removing 'build/bdist.linux-armv7l/egg' (and everything under it)
Processing max31855-2.0-py3.7.egg
Removing /usr/local/lib/python3.7/dist-packages/max31855-2.0-py3.7.egg
Copying max31855-2.0-py3.7.egg to /usr/local/lib/python3.7/dist-packages
max31855 2.0 is already the active version in easy-install.pth

Installed /usr/local/lib/python3.7/dist-packages/max31855-2.0-py3.7.egg
Processing dependencies for max31855==2.0
Finished processing dependencies for max31855==2.0

6- Trying the test script again

pi@raspberrypi:~/Python/Essais_MAX31855/max31855 $ cd ..
pi@raspberrypi:~/Python/Essais_MAX31855 $ ls
Essai_MAX31855_V1.py  max31855
pi@raspberrypi:~/Python/Essais_MAX31855 $ python3 Essai_MAX31855_V1.py 
Traceback (most recent call last):
  File "Essai_MAX31855_V1.py", line 1, in <module>
    from max31855 import MAX31855, MAX31855Error
ImportError: cannot import name 'MAX31855' from 'max31855' (/home/pi/Python/Essais_MAX31855/max31855/__init__.py)
pi@raspberrypi:~/Python/Essais_MAX31855 $ 

I didn't do anything more on the OS...

Do you see any anomaly?

Thank You :-)