The problem
I am trying to add the sqlite module to my python script that uses 2.7.13 in the streamlabs chatbot app.
When I run my script from 2.7.13 idle it works no problem. However when I run it from the streamlabs chatbot it gives the error no module named _sqlite3.
The streamlabs chatbot allows you to select the directory of where your lib is which mine is set to. I checked the lib folder and it has an sqlite folder inside of it already.
https://streamlabs.com/content-hub/post/chatbot-scripts-desktop
I assume that the module would need to be placed where the other scripts are which is C:\users\user folder\app data\roaming\streamlabs chatbot\services\scripts. For example, the boiler plate example made on git hub here:https://github.com/AnkhHeart/Streamlabs-Chatbot-Python-Boilerplate/tree/master/Boilerplate shows a lib folder in the specific script folder where he can import his custom module. Would have to do the same thing to make sqlite work in the streamlabs chatbot?
Here is the code:
import sys
import os
import time
import sqlite
ScriptName = "VLC Search and play"
Website = "twitch.tv/masterjx9"
Description = "VLC search and play app"
Creator = "masterjx9"
Version = "1.0.0"
settings = {}
searchRequest = ""
resetTime = 0
#more stuff
Here is the result in idle python:
>>>
#which is perfect
Here is the result in streamlabs chatbot:
no module named _sqlite3
Any ideas or suggestions would be awesome. Thank you
I was able to find my own answer thanks to the Streamlabs chatbot discord channel.
Streamlabs uses ironpython instead of python and they handle somethings different. They were able to give me an example of a script that uses a sqlite db and the major difference is that you need the following in order for sqlite3 to be imported:
import clr
clr.AddReference("IronPython.SQLite.dll")
clr.AddReference("IronPython.Modules.dll")
#Now you can import SQLite as shown in the line below
import sqlite3
#no errors in the chat bot
Hope this helps for anyone else.
I'm getting an error when trying to run my packaged python application in cmd line:
ModuleNotFoundError: No module named 'django.contrib.admin.apps'
I tried the answer from pyinstaller 3.2 with django 1.10.1, but I still get the same error. The only difference is a ModuleNotFoundError rather than an ImportError. Does anyone know what I could be doing wrong?
In the PyInstaller/hooks/ location you should add the hook file and import hidden modules.
More: https://github.com/pyinstaller/pyinstaller/issues/2332
I'm getting the following error while running the python program. I'm using python 3.4 and I have installed Ferenda-0.1.7-py3.4 And the error is:
File "C:\Python34\lib\site-packages\ferenda-0.1.7-py3.4.egg\ferenda\util.py", line 20, in module
from ast import literal_eval
ImportError: cannot import name 'literal_eval'
Appreciate you help on this. Thank you.
When I tried running in the command prompt. I can see no errors. Attached is the picture
You have named your script ast.py (or you have another script in the same directory named ast.py) and this script does not contain a literal_eval.
Im trying to compile Godot engine following the instructions here
When I run scons bin/godot as the tutorial says, I get the following error:
scons: Reading SConscript files ...
ImportError: cannot import name _args_from_interpreter_flags:
File "/home/grayfox/github/godot2/godot/SConstruct", line 9:
import multiprocessing
File "/usr/lib64/python2.7/multiprocessing/__init__.py", line 65:
from multiprocessing.util import SUBDEBUG, SUBWARNING
File "/usr/lib64/python2.7/multiprocessing/util.py", line 40:
from subprocess import _args_from_interpreter_flags
The SConstruct file starts this way:
EnsureSConsVersion(0,14);
import string
import os
import os.path
import glob
import sys
import methods
import multiprocessing
...
If I try to run python SConstruct I get an error complaining about missing functions defined by scons (i.e. the script fails after doing all the imports).
Commenting import multiprocessing fixes the issue but I don't want to modify that file, as I would have to revert the change if I ever make a pull request. The project is quite active so I believe this has something to do with my local configuration.
Any ideas why the script is failing to import _args_from_interpreter_flags only if I execute it via scons?
[UPDATE]
I did a fresh Gentoo install and the problem persists. I did some tests and I found this:
In a python terminal>
>>> import SCons.Script
>>> from subprocess import _args_from_interpreter_flags
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name _args_from_interpreter_flags
>>> import subprocess
>>> subprocess.__file__
'/usr/lib64/python2.7/site-packages/SCons/compat/_scons_subprocess.pyc'
But the output is different if I do this:
>>> import subprocess
>>> subprocess.__file__
'/usr/lib64/python2.7/subprocess.pyc'
So I update my question: Is this a bug? Can anybody reproduce it in other distros? If it's a bug, should I report it to Gentoo or to SCons?
[ANOTHER UPDATE]
Adding temp.extend([os.path.join(x, 'lib64') for x in prefs]) did't work, same error.
Adding print sys.path at the beginning of the compact module gives:
['/usr/lib64/python-exec/python2.7/scons-local-2.3.0',
'/usr/lib64/python-exec/python2.7/scons-local',
'/usr/lib64/python2.7/site-packages/lib32/scons-2.3.0',
'/usr/lib32/scons-2.3.0',
'/usr/local/lib32/scons-2.3.0',
'/usr/lib64/python2.7/site-packages/lib/python2.7/site-packages/scons-2.3.0',
'/usr/lib/python2.7/site-packages/scons-2.3.0',
'/usr/local/lib/python2.7/site-packages/scons-2.3.0',
'/usr/lib64/scons-2.3.0',
'/usr/lib64/python2.7/site-packages/lib32/scons',
'/usr/lib32/scons',
'/usr/local/lib32/scons',
'/usr/lib64/python2.7/site-packages/lib/python2.7/site-packages/scons',
'/usr/lib/python2.7/site-packages/scons',
'/usr/local/lib/python2.7/site-packages/scons',
'/usr/lib64/scons',
'/usr/lib64/python2.7/site-packages/RBTools-0.6-py2.7.egg',
'/usr/lib64/python27.zip',
'/usr/lib64/python2.7', #It's here, so what's the problem?
'/usr/lib64/python2.7/plat-linux2',
'/usr/lib64/python2.7/lib-tk',
'/usr/lib64/python2.7/lib-old',
'/usr/lib64/python2.7/lib-dynload',
'/usr/lib64/python2.7/site-packages',
'/usr/lib64/python2.7/site-packages/gtk-2.0',
'/usr/lib64/python2.7/site-packages/wx-2.8-gtk2-unicode']
It looks as if this isn't really a problem connected to SCons directly. You might have an alien "subprocess" module/package installed in your system. Also check out Cannot import name _args_from_interpreter_flags which seems to be related.
Based on your updated question: I tried to compile Godot on my machine (Python 2.7.3, SCons 2.3.1, Ubuntu 12.04 LTS) and it's running fine, so the problem is not related to the provided SConstruct (and its supporting build description files in subfolders). The "_scons_subprocess" module gets used only when the import of the original "subprocess.py" fails. So I suspect that the SCons start script sets up a wrong sys.path, which may happen under 64bit (see issue http://scons.tigris.org/issues/show_bug.cgi?id=2657 ).
After you added "temp.extend([os.path.join(x, 'lib64') for x in prefs])", your "print sys.path" statement shows paths like "/usr/lib64/python-exec" in its output. A Google search turned up the page http://forums.gentoo.org/viewtopic-t-985402-start-0.html for me. It describes an issue with Gentoo, where programs are installed as links to pip. Please follow the given advice and see if this fixes your problem.
It's a bug in Gentoo's scons-2.3.0 and scons-2.3.1 ebuilds (see bug report). It has been fixed in versions 2.3.1-r1 and higher.
I am running Apache2 on Ubuntu 9 with python 2.6.2 installed. I get the following error when I try to access a page on my django application:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 42, in load_middleware raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))ImproperlyConfigured: Error importing middleware django.middleware.common: "No module named _md5"
Here is my wsgi file:
import os, sys
sys.path.append('/etc/apache2/sites-available/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'dynamicuddi.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
From what I've read I think it's a python path problem but I haven't seen an actual solution to this that has worked. Any ideas?
Thanks in advance.
Try to append to python path you project directory and parent one
sys.path.append('path_to_dynamicuddi_project')
sys.path.append('path_to_dynamicuddi_parent_dir')
I don't think this is a pathing issue, like the one here.
I think it's finding the django.middleware.common module just fine and attempting to import it, but that module is causing an ImportError by trying to import "_md5."
You might want to have a look at this rather lengthy thread where Graham Dumpleton attempts to address this very problem: http://www.mail-archive.com/django-users#googlegroups.com/msg30630.html
Failing that, I would recommend you post the contents of the MIDDLEWARE_CLASSES tuple from your settings.py.
Also, what version of Django are you running?
So to wrap this up, we ended up re-installing the OS. I know this is a cop out but it fixed the problem for us.
Thanks for everyone's help!