I'm trying to write a python script for BusyBox on ESXi with mail functionality. It runs Python 2.5 with some libraries missing (i.e. the smtplib). I downloaded Python2.5 sources and copied the lib-folder to ESXi. Now I am trying to import the smtplib via "import lib.smtplib" but Python says:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/pysexi/lib/smtplib.py", line 46, in <module>
import email.Utils
File "/pysexi/lib/email/__init__.py", line 115, in <module>
setattr(sys.modules['email'], _name, importer)
KeyError: 'email'
I'm stuck. So every help and every thought is appreciated!
Trying to install generic applications on an appliance or custom OS is always fun.
Just a guess, but it may be that the email lib is a compiled C module - i.e. not pure python.
I would try use libraries that are as completely python with no compiled code - I don't know if there are pure python versions of the libraries.
The option is to try to track down what OS version that ESXi is based on and then use the matching python version from that OS.
I don't know anything about BusyBox or ESXi - therefore this may be more of a suggestion than an answer, but you might consider using a email service that supports an HTTP or RESTful API - such as MailGun. They have a free plan for up to 200 emails a day, so it might not cost you anything.
Again, this way be more of a suggestion or a plan "B" (if no one can help you with this specific problem)
Related
First of all, let me start out by saying, I am using gdb version 7.7 built --with-python
the python version is 2.6.x
And No I cannot upgrade them, since I'm limited by the devtools specifically meant for debugging my companies code.
There a lot of useful gdb-python scripts but all of them require me to
import gdb.printing
But I get an import error
(gdb)python import gdb.printing
Traceback (most recent call last):
File "<string>", line 1, in ?
ImportError: No module named printing
Error while executing Python code.
Is there any way to get the gdb.printing module in this version of gdb and python? (python3 works fine).
I would really appreciate any inputs for this.
I'm having a problem accessing Gmail account. Currently, I'm using this library written in python 2.7+ to log in and to read Gmail messages. To use the library, I had to enable Google 'insecure app'. Everything is working fine with this lib.
Now, I'm moving to python 3+, and I cannot use the lib anymore. Whenever I import the lib, it throws the following error:
import gmail
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/gmail-0.0.5-py3.6.egg/gmail/__init__.py", line 16, in <module>
File "/usr/local/lib/python3.6/site-packages/gmail-0.0.5-py3.6.egg/gmail/gmail.py", line 5, in <module>
ModuleNotFoundError: No module named 'utf'
I tried to overcome this problem by looking at a replacement module for 'utf' in python 3+ but I couldn't figure out what it is. How can I fix that?
Another problem is that I tried the official python lib provided by Google. Here is the link for the tutorial. I successfully completed the quick start example, but the script opened my browser, and I had to allow the access via the browser. In fact, I just want to create a cronjob to run my script periodically on my server without an UI. Does Google allow it?
Thank you very much.
The official API for Gmail that works in python 3
and there are a lot of guides for using it, for example:
https://github.com/abhishekchhibber/Gmail-Api-through-Python
But if you feel this is too complicated (I do), instead you may want to activate access using POP3 or IMAP from the Gmail settings panel.
Then use poplib or imaplib.
Example: https://docs.python.org/3/library/poplib.html#pop3-example
This is in general easier, more portable and uses packages already found in default python installs.
Edit:
The library you were using used IMAP access, not oauth.
Also to answer your "UTF" question: every string in python 3 is UTF8 by default, if you want to decode raw data, you should use 'mystring'.decode('utf-7'), etc.
Edit 2: looks like someone already did the work: https://github.com/charlierguo/gmail/pull/48
OK, I just saw the problem in the instructions:
So, I guess your only alternative is to stick with POP3/IMAP (which your program was already using).
I am currently experimenting with a python API for Snapchat that was derived from the PHP API. I am running my program from a Windows 10 laptop from Asus. It seems that I am getting a consistent error that is telling me I need to update my software OS or update Snapchat, which is weird because I have the latest version of windows and there is no Snapchat on windows.
After researching the problem, it seemed it was a common message given on jailbroken phones in an attempt to counter third party developers. It seems that I am the only one having this problem, as I looked around the internet and no one else seemed to complain. Could Someone please help me get around this issue and explain why this is occurring? Thank you in advance
>>> import pysnap
>>> snapchat = pysnap.Snapchat()
>>> snapchat.login('username', 'password')
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
snapchat().login('username', 'password')
File "build\bdist.win32\egg\pysnap\__init__.py", line 113, in login
raise Exception(result.get('message', 'unknown error'))
Exception: You're using a version of Snapchat or operating system that's no longer supported. Please upgrade your device's operating system and update to the newest app version to use Snapchat. Thanks!
I don't know that I have a solution, but it looks like several similar libraries have dealt with problems as well:
SnapchatBot
https://github.com/agermanidis/SnapchatBot/issues/52
Snapchat PHP SDK
https://github.com/liamcottle/Snapchat-SDK-PHP/issues/38
It does look as though the PHP SDK solved the problem, though it doesn't look like the solution is explicitly stated there.
I am trying to work with OpenCV in Python 2.7, however when I simply import cv2, I am getting this error:
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "cv2.py", line 9, in <module>
from VideoCapturePlayer import *
ImportError: No module named VideoCapturePlayer
I figured that VideoCapturePlayer may be in pygame or pycam, but when I import both, no problems arise.
I have searched my folders and the web for VideoCapturePlayer. My folders do not contain it, and the internet provided a .py file, but I do not know where I should put it. Any help is greatly appreciated, thank you.
Edit: I guess I should include that I am on Windows 7 64-bit
The link you provided is for downloading the entire OpenCV project, including all the libraries and bindings for C++, Java, etc. etc. For the Python bindings, it's much easier to visit my favorite module site on the Internet, Christoph Gohlke's Python Extension Packages for Windows repository. Find the OpenCV section, pick AMD64 or Win32, pick py2.7 or py2.6, and wait a bit for the self-extracting archive to download. Run it, hit OK for all the prompts, and you should be all set. Fire up IDLE or run python from the command line, and running import cv2 should give you no response at all - indicating that everything got set up just fine.
Good luck!
While reading the code for django/forms/widgets.py, I saw:
from util import flatatt
To dig deeper, I tried to import the util module in a Python shell in my terminal, but I got an error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named util
This left me confused. What is wrong?
Django is (ab?)using Python's import system in order to import something from django.forms.util. Import that module instead.
In python, you get this ImportError:
Traceback (most recent call last):
File "b.py", line 3, in <module>
from util import flatatt
ImportError: No module named util
Some programmer out there created a library for your python script to use. Your program was unable to find that library. So the interpreter tells you that it can't be found. You have a few options. Either you have to define the library and functionality yourself, or you'll have to review the instructions and source code of the program you are trying to run, and try to figure out what is broken to prevent the library from being included. Or the final option is to remove any usage of that library in the current script.
You can define the module yourself like this:
Put this in util.py in the same directory as your widgets.py file.
def flatatt(prompt):
print("ok")
If you define that, you will get a different error, the script will import your library, and find that method, but then will do the wrong thing, because the programmer who designed that code probably had some other functionality in mind.
You need to figure out what you did wrong, or what the original programmer did wrong, or how your specific system is different to cause this to work.
You can learn more about what I've described above here, by rolling your own python modules: Python: How to import other Python files
Often times these sorts of bugs are barriers to entry, the original developers don't want programmers who don't know the difference between an integer and a module using the software. So little problems like this are added, to help encourage you that you need to develop a better understanding of the source code under the hood. It's like a mechanic helping everyone become better mechanics by swapping the wires on the distributor cap. It isn't going to work until you swap them back rightly.
from django.forms.utils import flatatt
It worked with django 1.11 version, and may work with 1.8 through 1.10