0

I was coding a code for my Arduino UNO, and I followed a tutorial because this was the first time I had used python on a Arduino UNO. The guy in the tutorial used pip.main. I was just trying to get to a start on the code. I am using Python 3.7.5 and pip version 19.2.3. I have already tried looking around in Stack Overflow and other similar websites, but everything the community suggested didn't work. I also have very limited time to fix this problem. Here is my code:

try:
  from pyfirmata import Arduino, util
except:
  #the problem is here
  from pip._internal import main
  main(['install', 'pyfirmara'])
  from pyfirmata import Arduino, util

board = Arduino('')

iterator = util.Iterator(board)
iterator.start()

#code here

board.exit()

Help would be greatly appreciated!!

  • The interface of `pip` has changed. In general name starting with an underscore are considered private and might change without notice. You should not rely on them. – Klaus D. Nov 11 '19 at 03:52
  • Possible duplicate of [AttributeError: Module Pip has no attribute 'main'](https://stackoverflow.com/questions/49839610/attributeerror-module-pip-has-no-attribute-main) – phd Nov 11 '19 at 13:56
  • https://stackoverflow.com/search?q=%5Bpip%5D+main – phd Nov 11 '19 at 13:56

1 Answers1

0

The module pip._module is meant to be private and should not be used, as indicated by the leading underscore which is a Python convention.

The pip tool in general is not meant to be used as a library. See the pip documentation on "Using pip from your program" for details and alternative solutions.

sinoroc
  • 18,409
  • 2
  • 39
  • 70