gatorback
gatorback

Reputation: 1537

OS X: Multiple version of python 2.7.X

In order to install the Python module hidapi: I installed python 2.7 with home-brew:

brew install python2

I think it installed 2.7.15. Python information:

Users-MacBook-Air:~ user$ python -V
Python 2.7.10
Users-MacBook-Air:~ user$ which python
/usr/bin/python

I believe 2.7.10 was already installed (Apple OEM?).

The OS X command:

pip install hidapi

Indicates:

Requirement already satisfied: hidapi in /usr/local/lib/python2.7/site-packages (0.7.99.post21) Requirement already satisfied: setuptools>=19.0 in /usr/local/lib/python2.7/site-packages (from hidapi) (39.1.0)

Attempts to import HID from the Python command line results in error:

>>> import hid

Traceback (most recent call last): File "", line 1, in ImportError: No module named hid

There may be more than one version of 2.7 installed (2.7.15?).

  1. How can I test if a newer (second Python instance of 2.7.X) was installed today?
  2. How can I invoke Python 2.7.15 if was installed today?
  3. How can 2.7.10 be granted visibility to the hid module?

It I can invoke Python 2.7.15 and try to import the hid module, that should inch the troubleshooting process along.

UPDATE

Users-MacBook-Air:~ user$ python2

Python 2.7.15 (default, May 1 2018, 16:44:14) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin Type "help", "copyright", "credits" or "license" for more information.

>>> import hid
>>>

ONLY 2.7.15 has 'hid' visibility: the other two versions return an error.

Users-MacBook-Air:~ user$ python -V
Python 2.7.10
Users-MacBook-Air:~ user$ python2 -V
Python 2.7.15
Users-MacBook-Air:~ user$ python2.7 -V
Python 2.7.10

All pip references lead to the same place:

Users-MacBook-Air:~ user$ pip -V
pip 10.0.1 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)
Users-MacBook-Air:~ user$ pip2 -V
pip 10.0.1 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)
Users-MacBook-Air:~ user$ pip2.7 -V
pip 10.0.1 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)

Upvotes: 2

Views: 650

Answers (1)

OneCricketeer
OneCricketeer

Reputation: 191681

I think you've figured out the other questions, but

How can 2.7.10 be granted visibility to the hid module

You would need to install it using pip via easy_install however adding libraries into your system Python is usually frowned upon, which is why virtualenv's exist, but, you would need to install that module as well

Besides that, Python3 should generally be used for any new Python development

Upvotes: 2

Related Questions