Cannot import Bluetooth in Python 3 (OSX) - python

I reinstalled PyBluez some weeks ago since I couldn't get basic functions to work. Now I can't even import it to Python 3.
import bluetooth
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import bluetooth
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyBluez-0.22-py3.6.egg/bluetooth/__init__.py", line 47, in <module>
from .osx import *
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyBluez-0.22-py3.6.egg/bluetooth/osx.py", line 1, in <module>
import lightblue
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/lightblue/__init__.py", line 160, in <module>
from _lightblue import *
ModuleNotFoundError: No module named '_lightblue'
I was not able to install pybluez via pip/pip3, however I was able to install it by downloading the Github project. I have tried to update it, all suggestions I could find on matter online and much more.
I appreciate any help I can get.

This is the closed OS X import issue #108 on GitHub: http://github.com/karulis/pybluez/issues/108
It's actually quite an old issue. What version are you on? El Captain?
One thing the author suggested you might do is remove your current installation and install the GitHub repo using pip:
git clone https://github.com/karulis/pybluez.git
pip install -e pybluez
That seemed to get the import working for the OP of the GitHub issue, but there were still some bugs due to limited support of OS X. You can read more about the bugs and troubleshooting on GitHub.

Related

Python 3.6.8 - Jedi - ImportError: cannot import name 'traverse_parents'

<TL;DR>
When running import jedi in python 3.6.8 I get the following import error (see end of post for full traceback):
...
from jedi.common import traverse_parents
ImportError: cannot import name 'traverse_parents'
</TL;DR>
I checked in ~/.local/lib/python3.6/site-packages/jedi/common.py : There's a function called traverse_parents alright so there's definitely some witchery at work. Not the first time I've run into one of those "undefined name" problems, but I'm running out of ideas on this one.
Already tried :
uninstalling, reinstalling, upgrading the "jedi" package for pip3
pretty much the same jazz for a couple other packages with "jedi" in their names
upgrading pip3 to 20.2.1 and redoing the same reinstalling routine
installing jedi for python2 because why not (hey, it works fine in python2 but who cares)
also tried installing python-jedi from apt-get (I removed it afterwards)
incantations to ancient Babylonian demons (to no avail, they don't work Sundays)
Vague clues on how I might fix it :
getting the latest version of jedi from github and somehow installing it without making a mess (fat chance)
uninstalling jedi and reinstalling it from within Neovim (hey that might achieve the previous point)
I've scoured the web for the answer to this problem but I'm getting nowhere. Has anyone experienced something similar and managed to solve it ?
Any suggestion welcome.
The full traceback :
Error detected while processing function provider#python3#Call:
line 18:
Error invoking 'python_execute' on channel 5 (python3-script-host):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/vee/.local/lib/python3.6/site-packages/jedi/__init__.py", line 32, in <module>
from jedi.api import Script, Interpreter, set_debug_funcion, \
File "/home/vee/.local/lib/python3.6/site-packages/jedi/api/__init__.py", line 24, in <module>
from jedi.api import classes
File "/home/vee/.local/lib/python3.6/site-packages/jedi/api/classes.py", line 26, in <module>
from jedi.inference import imports
File "/home/vee/.local/lib/python3.6/site-packages/jedi/inference/__init__.py", line 70, in <module>
from jedi.inference import imports
File "/home/vee/.local/lib/python3.6/site-packages/jedi/inference/imports.py", line 24, in <module>
from jedi.inference import sys_path
File "/home/vee/.local/lib/python3.6/site-packages/jedi/inference/sys_path.py", line 8, in <module>
from jedi.common import traverse_parents
ImportError: cannot import name 'traverse_parents'
Fixed it :
I reinstalled the latest version of jedi via pip with this command :
pip3 install -e git://github.com/davidhalter/jedi.git#egg=jedi
Now, the command import jedi doesn't generate any exception and it seems to work alright in Neovim.
The reason why the default version installed with pip3 install jedi generated that ImportError is beyond what I can guess. Maybe this version was faulty itself, maybe some quirk of my python environment...
Edit: According to David Halter in the comment below, it seems to be a pip bug
Anyway. If you have the same problem, try this fix.

wxPython import error with Windows install

I have installed Python 3.4 and wxPython Phoenix on Windows 10. I go into Eclipse and add wxPython to the external libs in my project, but when I try to import it, I get this error:
Traceback (most recent call last):
File "C:\Users\linus\workspace\MiCS 1.2\main.py", line 1, in <module>
import wx
File "C:\Python34\Lib\site-packages\wx\__init__.py", line 17, in <module>
from wx.core import *
File "C:\Python34\Lib\site-packages\wx\core.py", line 6, in <module>
from ._core import *
ImportError: DLL load failed: The specified module could not be found.
I did some searching and tinkering and still can't figure out what's causing it. It shouldn't be the msvcp or msvcr DLLs as I have Office running just fine (or is that an incorrect assumption?) Any help is appreciated. Thanks.
How did you install wxpython?
As of now, the top page of the official site has wxpython 3.0 only for python27. So, I suspect you might not have installed it properly.
If you have your python34 at C:/Python34 then, cd to C:/Python34/Scripts first so that we make sure to use the pip for this python.
According to this post (https://groups.google.com/forum/#!topic/wxpython-dev/LmGIrQyh7jc), try
pip install -U --pre -f http://wxpython.org/Phoenix/snapshot-builds/ wxPython_Phoenix
This should find the corresponding whl file for your python version and CPU architecture.
Or, you could manually download whl file at http://wxpython.org/Phoenix/snapshot-builds/
If you have 32 bit Python34, then look for ******-cp34-none-win32.whl
and simply do:
pip install path/to/the/whl/that/you/just/downloaded/wxPython_Phoenix-3.0.3.dev1839+4ecd949-cp34-none-win32.whl
After this, if you can import wx in the normal cmd then the problem should be coming from eclipse.

cannot import Python-Twitter

I recently started out with python and i'm right now looking to do an app that shows my Twitter feed. So I downloaded a module(not sure if its called that) called Python-Twitter and installed it. But now everytime I try to import it I just get this error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import twitter
File "build\bdist.win32\egg\twitter.py", line 38, in <module>
File "C:\Python27\lib\site-packages\requests_oauthlib-0.4.0-py2.7.egg\requests_oauthlib\__init__.py", line 1, in <module>
from .oauth1_auth import OAuth1
File "C:\Python27\lib\site-packages\requests_oauthlib-0.4.0-py2.7.egg\requests_oauthlib\oauth1_auth.py", line 4, in <module>
from requests.utils import to_native_string
ImportError: cannot import name to_native_string
Does anyone know what I might have done wrong with the install or something? Thx
In my case installing requests-oauthlib fixed it
sudo pip install requests-oauthlib
This is because of requests version.
requests.utils.to_native_string is available since requests 2.0.0
So just update requests:
pip install -U requests
See more details here on another thread
This sounds like an issue with your install. The method to_native_string should be defined in the requests\utils.py in your Python install.
I'm on Ubuntu, and installed the Twitter module, and can import it without any errors. When I look in my install, in /usr/lib/python2.7/dist-packages/requests/utils.py, there is a to_native_string method defined there.
The implication from the error you're getting is that in your installation, there is either no utils.py, or, if there is, it does not contain that method.
I would recommend checking your install to see if that is the case. If it is indeed missing, I would recommend axing your install and reinstalling. You might want to try a virtualenv environment instead, so it can act as a sandbox (in that case you can leave your current install as is, as long as it is intact enough to run virtualenv and pip).
If utils.py is actually there and does contain a method with that name, I would recommend running a debugger such as pudb or pdb (pudb isn't built in, but it's more full featured), and step through the import to see if that sheds any additional light.

Error during library import in Python (Windows)

I am trying to configure svn hook for email notification using mailer.py script from apache, but it always crash on import of svn libs. I try two ways of installing svn and python. I try to install everything manually using command line and use CollableNet installer that have preinstalled Python and all libs I need but result is the same.
Now I try to import one library from hole package that I need using python in command line and I have such response:
>>> import svn.core
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named svn.core
I try to fix it using:
1) import sys; sys.path.append("C:\csvn\lib\svn-python\svn")
and
2) C:\csvn\lib\svn-python\svn>python "\__init__.py" install
But it didn't help.
For now I have no package with setup.py to install it.
I spend a lot of time on this task, and going crazy a little). Please give me any suggestion how to fix it.

ImportError: No module named qgis.core

I am on Ubuntu 13.04. I get the following error message -
Traceback (most recent call last):
File "analyse.py", line 1, in <module>
from log import shelve
File "/home/shubham/SMART/TaxiData/log.py", line 27, in <module>
from demo import *
File "/home/shubham/SMART/zones/demo.py", line 5, in <module>
from qgis.core import *
ImportError: No module named qgis.core
Actually, everything was working fine till today morning. I guess this might be due to a package update.
I tried looking around on Google but my search was fruitless. So, I will really appreciate any help or pointers you guys can give :)
Thanks.
I solved the problem by completely removing the installation and using the nightly builds at 'deb http://qgis.org/debian-nightly raring main'.
If you have pip installed you could either try pip search qgis or pip freeze. The latter shows a list of all installed python packages to check if you have the package. Maybe try reinstalling qgis ...
Try sudo apt-get install python-qgis . The package does not appear to be available on PyPI, but it was listed as "python-qgis" in the Ubuntu packages.

Categories

Resources