1

I am working on small python scripts. Basically i am not a python programmer and very new to it. Recently i have been working on IOT protocol MQTT. I have installed a open source MQTT clinet based on python3 in my raspberypi board. And now i am facing a problem. I have python 2.7 and 3.2 installed.

My MQTT client work with Python3.x and i want to use pyserial library also which i am not able to , i am getting a error

Serial module not found

I goggled a bit and end up here.. Now it say that you need to install pip3 in order to install pyserial for python3.x. I tried to install pip3 using this link , but end up installing pip2 using

pip install -U pip

I feel totally being messed up now. I just want to use pyserial while working with python3.x version.Can any one suggest me how?

Edit 1:

 On Linux, Mac OS X and other POSIX systems, use the versioned Python commands in combination with the -m switch to run the appropriate copy of pip:

python2   -m pip install SomePackage  # default Python 2
python2.7 -m pip install SomePackage  # specifically Python 2.7
python3   -m pip install SomePackage  # default Python 3
python3.4 -m pip install SomePackage  # specifically Python 3.4

I recently came through this documentation given here . But it even give a error to me /usr/bin/python3 : NO module named pip. main : 'pip' is a package and cannot be installed directly.

Community
  • 1
  • 1
shailendra
  • 271
  • 2
  • 6
  • 18

2 Answers2

2

Assuming you're using raspbian on your pi, you could install pip3 from the normal repositories:

apt-get install python3-pip

You can get the serial module the same way:

apt-get install python3-serial
ralight
  • 11,033
  • 3
  • 49
  • 59
1

I succeeded installing pyserial2.7 on a Mac running Yosemite and Python3.4 I entered the pyserial-x.y directory and run: python3 setup.py install

I got lot of errors that I corrected one by one by editing the files containing the syntax errors. Only 2 types of errors are encountered: - print needs () - except needs as instead of ,

So by correcting the dozen of errors with some patience, installation finish correctly. I wonder why a syntactically correct version for Python3 is not ready!

sanoj lawrence
  • 951
  • 5
  • 29
  • 69
Alexandre AMORTILA
  • 323
  • 1
  • 3
  • 6