[Tutor] Asking about pi_switch

Alex Kleider akleider at sonic.net
Thu Mar 2 20:14:11 EST 2017

On 2017-03-02 14:20, Quang nguyen wrote:
> Hi,
> Right now, I need to use pi_switch in order to send data through RF 
> system
> by Pi2. Until now, I installed everything it need from an article on 
> the
> internet. Those things are python-dev, libboost-python-dev, python-pip, 
> and
> I used pip to install pi_switch.
> I think it just compatible with python2, and I cannot import it to 
> python3.
> Are there any ways I can import it to python3 or execute python2 script
> which has pi_switch by python3 script?.
> Thanks

I'll assume you are using Raspbian as the OS on a Raspberry Pi.
Raspbian is a Debian based version of Linux.
python2.7 is the default but python3 is also there.
I suggest you use virtualenv as follows:

sudo apt-get install python-virtualenv
cd <your project directory>
virtualenv -p python3 venv
source venv/bin/activate  # This will leave you in a Python 3 
pip install py_switch  # I assume this is a RPi specific package

You can exit the environment with the following command:

You can get back into it by sourcing activate again as shown above.

Hope this is helpful.

I've been doing a lot of this sort of stuff with the Raspberry Pi and 
would be happy to keep the conversation going off line for the non 
Python bits.


More information about the Tutor mailing list