Go to advanced search

by croston
Fri Nov 10, 2017 12:43 pm
Forum: Python
Topic: idle in virtual environment
Replies: 6
Views: 303

Re: idle in virtual environment

BTW, I was also misinformed by SO, It says to use pip3 install RPi.GPIO, actually, I used pip install RPi.GPIO in the virtual environment than it works. However I am not very clear on this, isn't pip is only for python 2 and pip3 is for python3? When creating a python virtual environment, you are s...
by croston
Mon Nov 06, 2017 12:36 pm
Forum: Python
Topic: Building RPi.GPIO module
Replies: 1
Views: 184

Re: Building RPi.GPIO module

If you have built Python 3.6 from source then it is as simple as :

Code: Select all

# pip3 install RPi.GPIO
Note that edge detection will probably not work as it depends on /sys/class/* provided by the Linux kernel.

I don't know FreeBSD at all. Does it provide /dev/mem? RPi.GPIO needs this too.
by croston
Sun Nov 05, 2017 10:16 am
Forum: Weather station
Topic: Help with python scratch module
Replies: 13
Views: 1270

Re: Help with python scratch module

I am the author of the 'scratch' python module. It is currently released as an alpha release. This means that you need to add the --pre flag to install it with pip. I did the release over five years ago now so I think it is long overdue in changing from alpha to production status! My apologies to e...
by croston
Sun Sep 24, 2017 10:10 am
Forum: Weather station
Topic: Troubles installing Stretched Raspbian
Replies: 28
Views: 1974

Re: Troubles installing Stretched Raspbian

Obligatory XKCD:
https://xkcd.com/149/
by croston
Thu Aug 17, 2017 12:49 pm
Forum: General discussion
Topic: Raspbian Stretch (9.1) has arrived !!
Replies: 129
Views: 14559

Re: Raspbian Stretch (9.1) has arrived !!

Martin Frezman wrote:
Thu Aug 17, 2017 12:47 pm
runboy93 wrote:
Thu Aug 17, 2017 11:02 am
Fresh image is always less risk.
If you don't care about your data or installed programs.
It's a good way to test your backups are fit for purpose.
by croston
Wed Aug 16, 2017 7:40 pm
Forum: Troubleshooting
Topic: Activating virtual environment in cron
Replies: 3
Views: 273

Re: Activating virtual environment in cron

This might work:

Code: Select all

30 12 * * 1-5 /home/pi/myvenv/bin/python script.py
I'm not at a computer to test at the moment but I think this is what has worked for me before.
by croston
Sun Jul 30, 2017 2:19 pm
Forum: Python
Topic: Help! SyntaxError: Invalid Syntax
Replies: 2
Views: 317

Re: Help! SyntaxError: Invalid Syntax

What version of Python are you using? F-strings are only available in Python 3.6 onwards. F-strings replace the use of '.format' that you are also using.
by croston
Thu Jul 27, 2017 11:45 pm
Forum: Python
Topic: Invalid syntax
Replies: 1
Views: 207

Re: Invalid syntax

It's missing a closing bracket on the line above.

Lesson: when you get an error on a lime of code, the mistake is often found on the line above.
by croston
Sun Jul 23, 2017 4:06 pm
Forum: Beginners
Topic: Dumb python newbie question
Replies: 12
Views: 731

Re: Dumb python newbie question

Python 3 was released back in Feb 2009. It is very much mature. Python 2 support will end in 2020.
See the countdown timer at https://pythonclock.org.

The main problem these days is that there are a lot of examples and tutorials left lying around the web that still use Python 2.
by croston
Sun Jul 23, 2017 7:48 am
Forum: General discussion
Topic: Executable file
Replies: 12
Views: 976

Re: Executable file

It is possible that removable media is being automatically mounted with the 'noexec' flag set.
by croston
Thu Jul 20, 2017 6:41 pm
Forum: Beginners
Topic: RPi.GPIO question: to BOARD or to BCM?
Replies: 6
Views: 459

Re: RPi.GPIO question: to BOARD or to BCM?

DirkS wrote:In RPi.GPIO the default is BCM
That is incorrect - there is no default. You have to choose GPIO.setmode(GPIO.BCM) or GPIO.setmode(GPIO.BOARD) before running any GPIO code or it will raise an exception.
by croston
Wed Jun 14, 2017 8:23 pm
Forum: Off topic discussion
Topic: python
Replies: 9
Views: 834

Re: python

Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out. -- G...
by croston
Sun Jun 11, 2017 4:14 pm
Forum: Troubleshooting
Topic: Multiprocessing Virtual Environment: import module fails
Replies: 9
Views: 466

Re: Multiprocessing Virtual Environment: import module fails

You can use sudo with Python virtual environments if you specify the path of the Python interpreter used in your venv. In other words to run your script:

Code: Select all

$ sudo cv/bin/python startScript.py
by croston
Thu Jan 12, 2017 4:13 pm
Forum: General discussion
Topic: Question on GPIO Pins
Replies: 5
Views: 554

Re: Question on GPIO Pins

RTFM: https://sourceforge.net/p/raspberry-gpio-python/wiki/BasicUsage/ At the end any program, it is good practice to clean up any resources you might have used. This is no different with RPi.GPIO. By returning all channels you have used back to inputs with no pull up/down, you can avoid accidental ...
by croston
Thu Jan 05, 2017 6:14 pm
Forum: Python
Topic: Daemonization of Python script
Replies: 6
Views: 1172

Re: Daemonization of Python script

I have written a blog post about this topic:
http://wyre-it.co.uk/blog/converting-fr ... o-systemd/
by croston
Wed Dec 14, 2016 12:13 am
Forum: Troubleshooting
Topic: After install python 3.5 - RPi.GPIO not working
Replies: 3
Views: 2463

Re: After install python 3.5 - RPi.GPIO not working

How did you build/install Python 3.5? You seem to be missing some SSL support in Python, possibly as a result of missing dependencies when you built it. My guide to building and installing Python 3.5 on Raspbian Jessie should fix the problem for you. Make sure that you set RELEASE to 3.5.2 (the late...
by croston
Mon Nov 28, 2016 6:00 pm
Forum: Automation, sensing and robotics
Topic: Simple GPIO problem
Replies: 12
Views: 1193

Re: Simple GPIO problem

DougieLawson wrote:GPIO.setup() sets the pin as input or output, GPIO.output() sets the output pin as high or low. The two functions are not interchangeable.
Not quite true. You can use the 'initial=' keyword parameter on a setup() call to also do an output() when you are setting up a channel.
by croston
Wed Nov 23, 2016 11:09 am
Forum: Python
Topic: How to Manage Multiple Python Processes
Replies: 10
Views: 1723

Re: How to Manage Multiple Python Processes

You might want to take a look at Python's asyncio mechanism. There is some useful reading here: https://pymotw.com/3/asyncio/
by croston
Thu Nov 03, 2016 6:16 am
Forum: Python
Topic: gpio.add_event_detect disabled by os.system
Replies: 6
Views: 960

Re: gpio.add_event_detect disabled by os.system

I have not made a Wheezy image this time because I expect those expert enough to maintain an old distribution would know how to install it using pip.
by croston
Sun Oct 30, 2016 11:41 am
Forum: Python
Topic: gpio.add_event_detect disabled by os.system
Replies: 6
Views: 960

Re: add-event-detect disabled by os.system

I will be fixing this today - a new release of RPi.GPIO will appear in the next day or so.
by croston
Fri Oct 28, 2016 8:46 am
Forum: Troubleshooting
Topic: After install python 3.5 - RPi.GPIO not working
Replies: 3
Views: 2463

Re: After install python 3.5 - RPi.GPIO not working

How are you installing it? I suggest: $ sudo pip3.5 install RPi.GPIO Note that Python libraries live separately for each version of Python. In other words, you have to install the libraries that you need again for Python 3.5, using pip. Apt-get will only touch libraries for the versions of Python th...
by croston
Wed Oct 19, 2016 3:13 pm
Forum: Python
Topic: A button to restart script GPIO
Replies: 6
Views: 622

Re: A button to restart script GPIO

joan wrote:This may be a known problem.

#127 os.system breaks event detection

https://sourceforge.net/p/raspberry-gpi ... ckets/127/
There should be a fix for this by the end of the day. A fix has been written, it's waiting for a thorough testing and release.
by croston
Mon Oct 17, 2016 7:09 am
Forum: Beginners
Topic: Using a service or a deamon
Replies: 5
Views: 622

Re: Using a service or a deamon

http://www.netzmafia.de/skripten/unix/linux-daemon-howto.html Usually , you want to make your daemon fork() twice , make it the session leader , set CWD and umask , close all file descriptors , react gracefully to UNIX signals , write to log and PID-files etc. All those topics are worth a Google , ...
by croston
Wed Sep 28, 2016 4:34 pm
Forum: Python
Topic: Rpi and Python webapp
Replies: 4
Views: 662

Re: Rpi and Python webapp

I have written a guide to installing an up to date Django toolchain under Raspbian Jessie. The steps are suitable for a production environment but this does not stop you from using it for just 'tinkering'. It can be found here:

http://wyre-it.co.uk/blog/installing-dj ... -raspbian/
by croston
Thu Sep 22, 2016 7:12 am
Forum: Python
Topic: Drawing with Python
Replies: 9
Views: 1106

Re: Drawing with Python

@scruss and @tom.slick - what is it that you can do with Python 2 but not Python 3? Any libraries that have still not been ported in the 8 years since the release of Python 3 should be considered abandonware. Python 3 has been stable for years and will be up to version 3.6 by Christmas. Back to the ...

Go to advanced search