1

OS: Windows 10 64-bit
Language: Python 3.5.2 (Anaconda 4.2.0)
Problem Module: PyBluez 0.22 (PyBluez-0.22-cp35-none-win_amd64.whl)

When I attempt to import PyBluez after installation ie:

enter image description here

I am getting the following error:

enter image description here

I updated Spyder via pip and I have also tried uninstalling and re-installing the module via pip:

enter image description here

EDIT:

I only have python 3.5.2 installed:

enter image description here

Kieran
  • 89
  • 1
  • 13
  • 1
    Shouldn't it be `import bluetooth` instead of `PyBluez`? – kuro Apr 24 '17 at 12:18
  • I'm getting the same error when I try that, will update post with screenshot – Kieran Apr 24 '17 at 12:21
  • I’m guessing `python` is Python 2 for you, not Python 3, hm? – Konrad Rudolph Apr 24 '17 at 12:25
  • C:\Program Files\Anaconda3\Lib\site-packages>python Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> – Kieran Apr 24 '17 at 12:27
  • @Kieran In that case you should fix your configuration. `python` should be Python 2: http://legacy.python.org/dev/peps/pep-0394/ — Although to be honest I’m not sure this is related. – Konrad Rudolph Apr 24 '17 at 12:31
  • 1
    Check which python version does spyder use. Write a short script in spyder and execute it (`import sys; print sys.version_info` or print() with parenthesis if that fails) This is often the problem. Or try importing the bluetooth after you run python from the cmd (ie not from the spyder) – redacted Apr 24 '17 at 12:34
  • @KonradRudolph just to clarify, you're saying I should install python 2.x and then re-configure? Because I currently only have 3.5.2 installed – Kieran Apr 24 '17 at 12:35
  • @RobinNemeth This looks promising, I can `import bluetooth` from the command line, will investigate Spyder now – Kieran Apr 24 '17 at 12:36
  • 1
    @Kieran No, I’m saying that plain `python` should never refer to Python 3.x. *If* it exists, it should refer to Python 2.7. If you only install Python 3.x, the executable’s name should be `python3`. – Konrad Rudolph Apr 24 '17 at 12:38
  • @RobinNemeth the output from that script is: `sys.version_info(major=3, minor=6, micro=0, releaselevel='final', serial=0)` – Kieran Apr 24 '17 at 12:41
  • @KonradRudolph Thanks mate, naming convention is noted and I will implement as soon as I've nailed the current error – Kieran Apr 24 '17 at 12:44
  • 1
    @Kieran Well that solves the problem - spyder is using 3.6 while you installed it for the 3.5.2 in the command line. Now I dont really know how spyder works (try searching in the options for the path/to/python/version). A hackish soulition would be to do `import pip; pip.main(['install','PyBluez'])` from withing the script in spyder – redacted Apr 24 '17 at 12:47
  • @RobinNemeth Thanks for the help, I think I am going to try and investigate how I got multiple python versions and standardise the environment! – Kieran Apr 24 '17 at 12:52
  • Check out my answer for how to change the python version – redacted Apr 24 '17 at 12:53

1 Answers1

3

As per the comments. You installed the python package PyBluez for python3.5.2, but spyder is using 3.6.

This answer says

Press CTRL+SHIFT+ALT+P to open the Preferences window. Within this window, select the Console item on the left, then the Advanced Settings tab. The path to the Python executable will be right there.

to change the python executable.

A hackish solution is to run this from within the script in spyder import pip; pip.main(['install','PyBluez'])

Community
  • 1
  • 1
redacted
  • 3,789
  • 6
  • 25
  • 38