ImportError: No module named Foundation (lightblue) - foundation

Im trying to use the lightblue module for python, i installed it without problem, but when i try to import it, it gives me the error "ImportError: No module named Foundation" used inside lightblue. I've searched for that module (Foundation) but i haven't got a good answer on where to get it.
Any advice?
PS: Sorry for my bad english

export PYTHONPATH="/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/"
if it ask for the Foundation module.also check that your bluetooth is on and that you have replaced the last line (number 66) in setup.py like this:
os.system("xcodebuild install -arch 'x86_64' -target LightAquaBlue -configuration Release DSTROOT=/ INSTALL_PATH=/Library/Frameworks DEPLOYMENT_LOCATION=YES")
and last but not least check in _initblue.py (inside lightblue-0.4-master/src/mac) line 468 > replace with this one 'signature="v#:#iZ"' (double check it on goog)
you then run: 'sudo python setup.py install'
I have tried all these in 10.9 after many fails, but it then imported the module and found the bluetooth around me.good luck

Related

Cannot install using pip3 [duplicate]

I recently reinstalled ubuntu and did upgrade to 16.04 and cannot use python:
$ python manage.py runserver
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted
At this point, python itself doesn't work
$ python
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted
Even this suggestion is no longer working:
unset PYTHONHOME
unset PYTHONPATH
Every every I fix it one way, it comes back again. Several answers help to fix it temporarily, but not for good. I have reinstalled python and python3 several times. What can I do from here?
For Python-3 try removing virtual environment files. And resetting it up.
rm -rf venv
virtualenv -p /usr/bin/python3 venv/
source venv/bin/activate
pip install -r requirements.txt
https://wiki.ubuntu.com/XenialXerus/ReleaseNotes#Python_3
edit fo
For Windows10 User.
I was using python3.4 on Windows10. I installed python3.5. I couldn't find PYTHONPATH, PYTHONHOME env variable. If I command python in CMD console, It kept using python3.4. I deleted python3.4. Whenever I command python in CMD console, it starts showing an error like below.
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
I searched to figure out my problem. Solution was simple. When you install python3.5, you can custom install and check Add Python to environment variables in Advanced Options.
I just leave here for case that someone have similar issues visit here so that they don't waste their precious time much to figure out.
I was facing the same problem under Windows7. The error message looks like that:
Fatal Python error: Py_Initialize: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'
Current thread 0x000011f4 (most recent call first):
I have installed python 2.7(uninstalled now), and I checked "Add Python to environment variables in Advanced Options" while installing python 3.6. It comes out that the Environment Variable "PYTHONHOME" and "PYTHONPATH" is still python2.7.
Finally I solved it by modify "PYTHONHOME" to python3.6 install path and remove variable "PYTHONPATH".
For the same issue on Windows7
You will see an error like this if your environment variables/ system variables are incorrectly set:
Fatal Python error: Py_Initialize: unable to load the file system codec
ImportError: No module named 'encodings'
Current thread 0x00001db4 (most recent call first):
Fixing this is really simple:
When you download Python3.x version, and run the .exe file, it gives you an option to customize where in your system you want to install Python. For example, I chose this location: C:\Program Files\Python36
Then open system properties and go to "Advanced" tab (Or you can simply do this: Go to Start > Search for "environment variables" > Click on "Edit the system environment variables".) Under the "Advanced" tab, look for "Environment Variables" and click it. Another window with name "Environment Variables" will pop up.
Now make sure your user variables have the correct Python path listed in "Path Variable". In my example here, you should see C:\Program Files\Python36. If you do not find it there, add it, by selecting Path Variable field and clicking Edit.
Last step is to double-check PYTHONHOME and PYTHONPATH fields under System Variables in the same window. You should see the same path as described above. If not add it there too.
Then click OK and go back to CMD terminal, and try checking for python. The issue should now be resolved. It worked for me.
I had this error during migration to Ubuntu 17.10, and this solved the problem :
sudo dpkg-reconfigure python3
Maybe you will have to close your session and reconnect.
Look at /lib/python3.5 and you will see broken links to python libraries. Recreate it to working directory.
Next error -
./script/bin/pip3
Failed to import the site module
Traceback (most recent call last):
File "/home/script/script/lib/python3.5/site.py", line 703, in <module>
main()
File "/home/script/script/lib/python3.5/site.py", line 683, in main
paths_in_sys = addsitepackages(paths_in_sys)
File "/home/script/script/lib/python3.5/site.py", line 282, in addsitepackages
addsitedir(sitedir, known_paths)
File "/home/script/script/lib/python3.5/site.py", line 204, in addsitedir
addpackage(sitedir, name, known_paths)
File "/home/script/script/lib/python3.5/site.py", line 173, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "/home/script/script/lib/python3.5/types.py", line 166, in <module>
import functools as _functools
File "/home/script/script/lib/python3.5/functools.py", line 23, in <module>
from weakref import WeakKeyDictionary
File "/home/script/script/lib/python3.5/weakref.py", line 12, in <module>
from _weakref import (
ImportError: cannot import name '_remove_dead_weakref'
fixed like this - https://askubuntu.com/questions/907035/importerror-cannot-import-name-remove-dead-weakref
cd my-virtualenv-directory
virtualenv . --system-site-packages
I had deleted rm -r /usr/lib/python*
dpkg -S '/usr/lib/python3*' | grep encodings
And then found I needed libpython3.10-minimal
sudo apt-get install --reinstall libpython3.10-minimal
I finally ran
sudo apt-get install --reinstall $(dpkg -S '/usr/lib/python3*' | cut -d ':' -f1 | cut -d ',' -f1 | sort | uniq | tr '\n' ' ')
sudo apt-get install --reinstall $(dpkg -S '/usr/lib/python2*' | cut -d ':' -f1 | cut -d ',' -f1 | sort | uniq | tr '\n' ' ')
To re-install all the packages I deleted files for
Had the same problem when updating my mac to macOS Catalina, while using pipenv. Pipenv creates and manages a virtualenv for you, so the earlier suggestion from #Anoop-Malav is the same, just using pipenv to remove the virtual environment based on the current dir and reset it:
pipenv --rm
pipenv shell # recreate a virtual env with your current Pipfile
I was facing this issue "ModuleNotFoundError: No module named 'encodings" after updating to macOS Catalina.
I was having multiple versions of Python installed in my system.
Removing all the python versions(2.7 and 3.7.4) from macOS system and reinstalling the latest python 3.8 worked for me.
To remove a python from macOS, I've followed the instructions from here How to uninstall Python 2.7 on a Mac OS X 10.6.4?
The above link is for python 2.7 and but you can use the same for 3.7 also.
In my case just changing the permissions of anaconda folder worked:
sudo chmod -R u=rwx,g=rx,o=rx /path/to/anaconda
I got this error when try to launch MySql Workbench 8.0 on my macOS Catalina 10.15.3.
I solved this issue by installing Python 3.7 on my system.
I guess in future, when Workbench will have version greater than 8, it will require newer version of Python. Just look at the library path in the error and you will find required version.
I tried everything, deleted PYTHONPATH and PYTHONHOME - the error didn't go away. I had overlooked that I had specified a python-home path under WSGIDaemonProcess in the wsgi configuration of a VirtualHost. I removed that and the error was gone.
I had a similar issue. I had both anaconda and python installed on my computer and my python dependencies were from the Anaconda directory. When I uninstalled Anaconda, this error started popping. I added PYTHONPATH but it still didn't go.
I checked with python -version and go to know that it was still taking the anaconda path.
I had to manually delete Anaconda3 directory and after that python started taking dependencies from PYTHONPATH.
Issue Solved!
Because this is the first result in google I just want to add the following information for anybody else having problems with jails:
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007f079b16d740 (most recent call first):
Aborted (core dumped)
When attempting to import python into your jail you both need to link the dependencies and /usr/lib/pythonX.Y to [JAIL]/usr/lib/. Hope this helps.
I was facing same issue on a Debian server and for me the problem was that I've put my project inside the /root/ folder for which mod_wsgi didn't have the rights to access. So I simply moved my project into /var/www/html/ and update my VirtualHost configuration.
In my case, what worked was the following: I changed the env path in the conf from /home/vinzee/.pyenv/versions/envname/bin/ to /home/vinzee/.pyenv/versions/envname/ and it worked.
It seems the environment path needs to be the path to the root folder of the virtual environment (and not the path to ROOT_VENV/bin/).
You can additionally try without the trailing slash as others have suggested, but in my case, it worked both with and without it.
It seems this error can happen for a large variety of reasons (given the number of different answers on here).
For me, the issue was related to the fact that my app was deployed in a virtualenv, and the pyvenv.cfg file had the wrong permissions. It must be writable by the user uwsgi is running as (which in my case was http).
Just go to File -> Settings -> select Project Interpreter under Project tab -> click on the small gear icon -> Add -> System Interpreter -> select the python version you want in the drop down menu
this seemed to work for me
I could also fix this. PYTHONPATH and PYTHONHOME were in cause.
run this in a terminal
touch ~/.bash_profile
open ~/.bash_profile
and then delete all useless parts of this file, and save.
I do not know how recommended it is to do that !

Unable to use gitpython ImportError

Tried to run a script I wrote yesterday again today and ran into this:
ImportError: cannot import name 'Repo' from 'git' (/usr/local/lib/python3.7/site-packages/git/__init__.py)
I am at a complete loss. On a new computer so the only thing different install wise would have been that I installed pycharm. I am currently trying to run through bash shell on a mac. The exact code was running as excepted earlier, no code changes.
Things I have tried:
uninstalling/reinstalling python
uninstalling/reinstalling pip
uninstalling/reinstalling gitpython
Running on:
mac catalina
python version 3.7.6
pip version 20.0.1
As a side note, the script works as intended until the automated git push. Wondering if I should just make the os calls myself and not worry about this?
I really dont understand what I did/am doing wrong here.
EDIT:
Again, sorry as this is my first mac computer. I did a brew uninstall of python3 and reinstalled through the app store to 3.8.
ImportError: cannot import name 'is_cygwin_git' from partially initialized module 'git.util' (most likely due to a circular import) (/Library/Frameworks/Python.framework/
I know cygwin is for windows, but I figured I'd play along and trying a pip install pycygwin.
Install threw an error asking for cython, so I did another pip install and tried again. The pycygwin then complained gcc was missing so I did a brew install of gcc. With gcc installed and correctly on path, it still says it cant find it and exits with
build/cygwin/_cygwin.c:611:10: fatal error: 'sys/cygwin.h' file not found
#include <sys/cygwin.h>
^~~~~~~~~~~~~~
1 error generated.
error: command 'gcc' failed with exit status 1
Thinking I might just try a different package manager? Currently, an attempt to rerun the script yeilds
ImportError: cannot import name 'Repo' from partially initialized module 'git' (most likely due to a circular import)
To which I investigated but I shouldn't have any overlapping dependancies.
On the script throwing the error I'm using:
import csv
import yaml
import os
from git import Repo
and on the wrapper I made and imported, I'm using:
import subprocess
import re
Will update if I get any further on this, would love some suggestions.
EDIT:
Importing using just import git works throws a different error, like the python is trying to get itself?
ImportError: cannot import name '<file name>' from '<file name>'
If I change the file name and try to run it, it comes backs with:
ImportError: cannot import name '<old file name>' from '<old file name>'
***FIXED****
Uninstall of python through homebrew
Reinstall of python through mac app store
Uninstall/Reinstall of modules through pip
Saving the file under a new name and deleting the old one
Still have absolutely no idea why/how this happened but the above worked for me. If anyone knows why something like this can happen, I would love to know. Cheers.

Kivy Installation Guide for Windows 10

I've been trying to follow online youTube videos to install kivy on my Windows 10 computer (python-3.7.5-amd64, kivy 1.11.1). Aside from the fact that they seem to have different variations on how they approach the topic, I am unable to get a solution that operates satisfactorily.
These are the steps I am following:
I install python (python-3.7.5-amd64.exe) to C:\Python37
I modify the path to include to include the following: C:\Python37\Scripts;C:\Python37;C:\Python37\Libs;C:\Python37\DLLs;C:\Python37\Lib\site-packages;
I added the following environment variable PYTHONPATH = C:\Python37\DLLs;C:\Python37\Libs;C:\Python37;C:\Python37\Scripts;C:\Python37\Lib\site-packages;
I open a command window and type in the following commands (taken from kivy.org)
python -m pip install --upgrade pip wheel setuptools virtualenv
python -m pip install docutils pygments pypiwin32 kivy_deps.sdl2==0.1.* kivy_deps.glew==0.1.*
python -m pip install kivy_deps.gstreamer==0.1.*
python -m pip install kivy_deps.angle==0.1.*
python -m pip install kivy==1.11.1
python -m pip install kivy_examples==1.11.1
I try to run a simple program. From within Windows Explorer I right click the code file (label.py) and from the shortcut menu select python.
A windows pops up for an instant and a directory called __pycache__ gets created with kivy.cpython-37.pyc. Double clicking that causes the program to run.
Is it possible to have a easier solution in which the source code, once compiled executes?
If I open a command prompt and attempt to execute the source code using the command python label.py I get the following:
Traceback (most recent call last):
File "label.py", line 1, in <module>
from kivy.app import App
File "C:\Users\chrib\Google Drive\_Software\Python_Kivy\kivy.py", line 1, in <module>
from kivy.base import runTouchApp
ModuleNotFoundError: No module named 'kivy.base'; 'kivy' is not a package
Why should this happen?
Also is it possible to have a cleaner development environment. I am used to Visual Studio IDE and it would be great if I can use this environment.
Thanks
Code for label.py
from kivy.app import App
from kivy.uix.label import Label
class MyApp(App):
def build(self):
return Label(text='Hello world!');
if __name__=='__main__':
MyApp().run();
I've been trying to follow online youTube videos to install kivy on my Windows 10 computer
Have you tried simply following the instructions on kivy.org? There's no need to use youtube videos, the installation is largely a normal python module install.
I try to run a simple program. From within Windows Explorer I right click the code file (label.py) and from the shortcut menu select python.
Don't do this, run the file by opening a command prompt and typing python yourfilename.py. That way you will see the full traceback for any errors that occur.
A windows pops up for an instant and a directory called pycache gets created with kivy.cpython-37.pyc. Double clicking that causes the program to run.
It sounds likely that the first run is crashing. As above, you want to get the information about why.
Is it possible to have a easier solution in which the source code, once compiled executes?
When you run the code it does execute. As above, it's probably crashing.
ModuleNotFoundError: No module named 'kivy.base'; 'kivy' is not a package
Have you made a file named kivy.py? It looks likely that you have, and that this file is being imported in preference to the installed kivy module.
Also is it possible to have a cleaner development environment. I am used to Visual Studio IDE and it would be great if I can use this environment.
I'm not sure what you consider unclean about your development environment, but you should think in terms of python environments and their installed packages. Kivy is just a python module that you install into a python environment. When you use an IDE, it may integrate with one or more python environments (with options to switch between them). There's nothing special about using Visual Studio with Kivy, just do whatever you normally do to use it with Python.
I figured it out. I had a program in the code directory called kivy.py. I renamed that and it worked.

How to solve this ModuleNotFoundError: No module named '_sqlite3' in docker-debian

While trying to run scrapy spider in docker-debian every time I get an error:
File "/usr/local/lib/python3.6/site-packages/scrapy/crawler.py", line 82, in
crawl
yield self.engine.open_spider(self.spider, start_requests)
builtins.ModuleNotFoundError: No module named '_sqlite3'
python version 3.6.3
scrapy 1.6.0
tried instruction from this post - ImportError: No module named '_sqlite3' in python3.3
still see this error.
when type sqlite3 command in terminal it shows sqlite3 version and start sqlite terminal.
SQLite version 3.16.2 2017-01-06
when type python and write next command in terminal:
import sqlite3
get this error:
ModuleNotFoundError: No module named '_sqlite3'
is there any way to solve this problem? looks like there is some misconfiguration but I can't find where it's
I have the same error with sqlite3 while I was trying to start my crawler using scrapy crawl my-crawler, after some searches and tried out different solutions, I found this answer useful to my error. Just remember that you need to download your specific python version, mine was 3.8.1 and it worked thanks to their answer. I have already install sqlite3 using sudo apt install libsqlite3-dev. Hope it works in your case, too. So, at first install it then reconfigure your python via instructions in the link.
I had same problem in centos, I just fix it. I install multiple python version in pyenv, so I switch the python version from 3.6 to 3.4.1, then problem solved.Maybe the problem was caused by pyenv,or it's python version's problem. If you don't have pyenv,maybe you need to reinstall python,or install a diffrent version of python.Hope be helpful.

Python 3.6 cx_freeze ModuleNotFoundError: No module named Tkinter

I froze a python 3.6 program with cx_freeze, and it worked just fine. But as soon as I tried to run it, I got this error message.
Does anyone know what to do? Please help!
try using
import tkinter
(small 't' instead of capital)
Try checking the dir names in the 'lib' folder (in my case it was 'build\exe.win-amd64-3.6\lib'). I had a similar issue (without the 'ImportError: DLL load failed...') and found that the 'lib' directory contained a "Tkinter" folder. Changing its name to lowercase 'tkinter' did the trick and made the .exe run just fine.
If you read the error more clearly, it stated in a comment that if importing _tkinter failed, your computer isn't configured to use tkinter. You should download tk and ttk to make it work.
And According to http://wiki.python.org/moin/TkInter :
If it fails with "No module named _tkinter" or "Tkinter", your Python configuration
needs to be modified to include this module (which is an extension
module implemented in C). Do not edit Modules/Setup (it is out of
date). You may have to install Tcl and Tk (when using RPM, install the
-devel RPMs as well) and/or edit the setup.py script to point to the right locations where Tcl/Tk is installed. If you install Tcl/Tk in
the default locations, simply rerunning "make" should build the
_tkinter extension.

Resources