Go to advanced search

by robbes
Mon Mar 12, 2018 6:05 pm
Forum: Python
Topic: Running a Rasberry pi command from within a python prohramme
Replies: 1
Views: 302

Re: Running a Rasberry pi command from within a python prohramme

I'm obviously doing something wrong but my lack of knowledge and trial and error approach is frustrating. Is there a straight forward way of using a command line instruction within Python with the ability to have certain elements used as variables and then modified from within the python programme ...
by robbes
Wed Mar 07, 2018 6:54 pm
Forum: Python
Topic: getting the right information out of a line
Replies: 3
Views: 476

Re: getting the right information out of a line

Strange symbols would indicate a decoding problem from byte to string. If you are able to arrange for the incoming serial object to be a string rather than a byte string, it might simplify things.
by robbes
Mon Mar 05, 2018 6:25 pm
Forum: Python
Topic: getting the right information out of a line
Replies: 3
Views: 476

Re: getting the right information out of a line

It appears to me that you are mingling objects of type 'byte' and objects of type 'string', and that won't work. You need to decode the byte object, presumably with utf-8 and then do string operations on it. The state == 'c1' in this bit of your code will never be True since you have already appende...
by robbes
Thu Feb 22, 2018 5:42 pm
Forum: General discussion
Topic: Python Indentation
Replies: 6
Views: 987

Re: Python Indentation

It never hurts to run a python code checker such as flake8. You'll be surprised how many PEP8 conventions you may have broken.
by robbes
Sat Feb 17, 2018 5:26 pm
Forum: Troubleshooting
Topic: matplotlib does not display live the actual CPU temperature from a SCV file
Replies: 1
Views: 238

Re: matplotlib does not display live the actual CPU temperature from a SCV file

You might try eliminating all the scv file code, and just try matplotlib interactive mode directly.
Interactive mode is on, right?
by robbes
Thu Feb 08, 2018 6:13 pm
Forum: Python
Topic: Raspberry PI Zero W matplotlib
Replies: 1
Views: 401

Re: Raspberry PI Zero W matplotlib

You need to provide more information on the problem. Are you getting an error message? Are you not getting any output on plot()? Are you using the same screen on both systems?
by robbes
Wed Jan 24, 2018 6:16 pm
Forum: Python
Topic: PIP, how the hell do you batch upgrade.
Replies: 5
Views: 644

Re: PIP, how the hell do you batch upgrade.

The pip reference guide is also worth taking a look at:
https://pip.pypa.io/en/latest/reference/
by robbes
Wed Jan 24, 2018 5:23 pm
Forum: Python
Topic: PIP, how the hell do you batch upgrade.
Replies: 5
Views: 644

Re: PIP, how the hell do you batch upgrade.

There are several tools :
https://github.com/jazzband/pip-tools
https://github.com/simion/pip-upgrader

I personally generate upgrades using pip freeze, which is not recommended because of the lack of control,
by robbes
Mon Jan 22, 2018 7:56 pm
Forum: General discussion
Topic: Monochrome LCD 128/64 Display letter selection input?
Replies: 6
Views: 1119

Re: Monochrome LCD 128/64 Display letter selection input?

I like the 0.96 inch monochrome displays. You can get them on aliexpress for not much more than US$2 with an i2c interface. They have low power consumption and the display will reportedly last about 2 years under continuous use. Using python with the PIL and luma.OLED libraries you can easily set th...
by robbes
Wed Dec 27, 2017 5:24 am
Forum: Python
Topic: Problem with matplotlib
Replies: 3
Views: 1219

Re: Problem with matplotlib

I don't have a RaspberryPi with a screen at the moment, but I ran your program on a desktop machine and ignored all the GPIO things. From what I see, the interactive version of matplotlib only wants you to pass in the most recent data points, whereas you were trying to pass in the entire arrays ([x-...
by robbes
Tue Dec 26, 2017 6:20 pm
Forum: Python
Topic: Problem with matplotlib
Replies: 3
Views: 1219

Re: Problem with matplotlib

Warnings shouldn't affect the output.

Do you not have the arguments reversed in

Code: Select all

plt.plot([gainString], [x_axis])
?
by robbes
Mon Dec 18, 2017 7:19 pm
Forum: Advanced users
Topic: Disable USB ports
Replies: 14
Views: 18422

Re: Disable USB ports

RobW77 -
Did you follow the installation instructions at https://github.com/mvp/uhubctl ?
by robbes
Sun Dec 17, 2017 9:28 am
Forum: Python
Topic: Change output form of Python script
Replies: 7
Views: 1033

Re: Change output form of Python script

The order of the items in a list will not change. One problem you might have in the future: if you append more items to your dict. d, there is no guarantee that the order will stay the same. You would have to change your dictionary to an "ordered dictionary", but that is not difficult. You appear to...
by robbes
Sat Dec 16, 2017 10:52 pm
Forum: Python
Topic: Change output form of Python script
Replies: 7
Views: 1033

Re: Change output form of Python script

I'm not sure why your output is producing tuples if you used for key, value in d.items(): It should just give you some strings. I would get your output if I were to use for item in d.items(): but it isn't important. You may find it easier to use the output of l= list(d.values()) which is a list. Acc...
by robbes
Sat Dec 16, 2017 7:14 pm
Forum: Python
Topic: Change output form of Python script
Replies: 7
Views: 1033

Re: Change output form of Python script

If you do not need to use the properties of a python dictionary object, then d need not be defined as a dictionary - a tuple might be better. But to avoid a lot of reprogramming, you can simply access the values of your dictionary d using something along this line: for key, value in d.items(): print...
by robbes
Wed Dec 06, 2017 5:52 pm
Forum: Python
Topic: [SOLVED] Python3 and Matplotlib - no luck
Replies: 12
Views: 4495

Re: Python3 and Matplotlib - no luck

That's good. I upgraded to the November release of Stretch today, and matplotlib is working with all the backends I tried; I don't think you should associate the problem you had with the OS version. It was likely to have been a package installation issue. Anyway, try to edit the Subject Title to inc...
by robbes
Tue Dec 05, 2017 6:20 pm
Forum: Python
Topic: [SOLVED] Python3 and Matplotlib - no luck
Replies: 12
Views: 4495

Re: Python3 and Matplotlib - no luck

I am out of ideas. I assume you are using python3.5 and matplotlib v. 2.0.2 In your original post you mentioned installing pip3 and also a memory error. You shouldn't have had to install pip3. Possibly try reinstalling matplotlib and the cairo dependencies. Try all the backends and see if any of the...
by robbes
Tue Dec 05, 2017 7:02 am
Forum: Python
Topic: [SOLVED] Python3 and Matplotlib - no luck
Replies: 12
Views: 4495

Re: Python3 and Matplotlib - no luck

I decided to see if I had problems using the cairo backend of matplotlib on python3 in jessie; it seems OK after two packages are installed: sudo apt install python3-cairo sudo apt install libcairo2 There are a few references on stackexchange referring to a need for sudo apt install python3-gi but I...
by robbes
Mon Dec 04, 2017 7:47 pm
Forum: Python
Topic: [SOLVED] Python3 and Matplotlib - no luck
Replies: 12
Views: 4495

Re: Python3 and Matplotlib - no luck

Is your matplotlib installation configured to use the cairo backend? This will be stated in your matplotlibrc file. I think the location is normally in ~/.config/matplotlib/matplotlibrc. If not you can find it with >>> import matplotlib >>> matplotlib.matplotlib_fname() Look for a line that looks li...
by robbes
Fri Nov 17, 2017 8:45 am
Forum: Python
Topic: Followup question to "How to convert an integer to bytes() ...
Replies: 2
Views: 554

Followup question to "How to convert an integer to bytes() ...

Fortunately I have never had to use this conversion; after running a few lines of code I realized I was "missing something": for int in range(20): ... print(int.to_bytes(2, 'big')) yields b'\x00\x00' b'\x00\x01' b'\x00\x02' b'\x00\x03' b'\x00\x04' b'\x00\x05' b'\x00\x06' b'\x00\x07' b'\x00\x08' b'\x...
by robbes
Sun Nov 12, 2017 9:14 pm
Forum: Python
Topic: error using newline=
Replies: 3
Views: 871

Re: error using newline=

I don't know why you are getting an error, but I don't think you need the newline parameter (it defaults to newline=None); just be consistent when you read from the file object.

see https://docs.python.org/3/library/functions.html#open
by robbes
Sun Nov 12, 2017 5:40 pm
Forum: Python
Topic: Your python learning recommendations?
Replies: 5
Views: 862

Re: Your python learning recommendations?

I can Google and grab a ton of resources, but learning syntax doesn't show me "how" to program does it? I expect this is a common issue. I have hundreds of Python-related sites in my bookmarks, hundreds of Mb of free books, and many pages of "tips" I have collected. I enjoy the learning process, bu...
by robbes
Sun Nov 12, 2017 5:10 pm
Forum: Beginners
Topic: installing sqlite3 for node red
Replies: 2
Views: 2255

Re: installing sqlite3 for node red

You might find https://tech.scargill.net/sqlite-on-the-pi/ of interest.
Pete Scargill blogs a lot about Node Red and Raspberry Pi.
by robbes
Thu Nov 09, 2017 7:55 pm
Forum: Python
Topic: basic python question
Replies: 5
Views: 838

Re: basic python question

Only slightly off-topic: The enumerate method provides an option for you to specify the starting value of the index in an enumerated list. For example, to have the first value of the index as 1 rather than the default 0: mylist = [2, 4, 6, 8] for index, item in enumerate(mylist, 1): print(index, ite...

Go to advanced search