python-gnupg vs forked python-gnupg - python

I am trying to use the forked version of python-gnupg: https://pypi.org/project/gnupg/
rather than the original: https://pypi.org/project/python-gnupg/
When I install "gnupg" to my conda environment I see this:
$conda list | grep gnupg
gnupg 2.2.17 he1f381d_0
but when I try to import that module, I get this not found error:
(my_env) $python
Python 3.7.7 (default, May 7 2020, 21:25:33)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gnupg
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'gnupg'
>>> import pretty_bad_protocol
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pretty_bad_protocol'
>>> from pretty_bad_protocol import gnupg
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pretty_bad_protocol'
The docs for the forked version say to import gnupg and pretty-bad-protocol, but neither work for me. I can't figure out what I'm doing wrong. Has anyone else had success with this module? Thanks!

Related

Why does Python seem to be using two interpreters at once?

I used to use pyenv as my version manager but it had too much trouble installing packages so I'm moving over to virtualenv. So when I activate my virtual environment and write: which python I get:
/Users/kylefoley/codes/venv/bin/python
But when I actually use python it seems that it is still using pyenv. For example:
(venv) Admins-MacBook-Pro-4:~ kylefoley$ python
Python 3.8.0 (default, Nov 28 2019, 02:43:40)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'Tk'
>>> import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'Tkinter'
>>> import tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/kylefoley/.pyenv/versions/3.8.0/lib/python3.8/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
I'm not trying to fix the problem of not being able to use Tkinter rather I just want to understand why this line:
File "/Users/kylefoley/.pyenv/versions/3.8.0/lib/python3.8/tkinter/__init__.py", line 36, in <module>
is coming up.
It's because I created the virtual environment when my version management was still pyenv. If I eliminate that version management, then I do not get the file pyenv.cfg but instead get the file: pip selfcheck.json which is located in the virtual environment directory together which lib, bin and include.

Python 3.6, Wine and asyncio - ImportError: cannot import name '_overlapped'

I'm trying to install Flask inside Wine so that I can package with cx_freeze. I've had it working for a while, but I've just added Flask to the project.
However, I can't seem to import Flask due to a missing library required by the core asyncio library. The cause of this is an import that is only included in windows systems called _overlapped. The code can be seen here.
I can confirm that there is a library contained within the dlls folder:
root#375a857194f3:/src# find /root/.wine -iname *overlapped*
/root/.wine/drive_c/Python36/DLLs/_overlapped.pyd
An example import and error message can be found below.
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
Traceback (most recent call last):
File "C:\Python36\lib\asyncio\__init__.py", line 16, in <module>
from . import _overlapped
ImportError: cannot import name '_overlapped'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python36\lib\asyncio\__init__.py", line 18, in <module>
import _overlapped # Will also be exported.
OSError: [WinError 10045] Windows Error 0x273d

Howto install psycopg2 in virtualenv with mx support?

I have a virtualenv venv where I installed mx-base and psycopg2 with pip:
$ pip freeze | grep "psyco\|mx"
egenix-mx-base==3.2.8
psycopg2==2.6
The basics of psycopg2 works but when using extensions I get exceptions like this:
Traceback (most recent call last):
File "/my_proj/my_code.py", line 32, in <module>
register_types()
File "/my_proj/my_code.py", line 28, in register_types
psycopg2.extensions.register_type(psycopg2._psycopg.MXDATETIME)
AttributeError: 'module' object has no attribute 'MXDATETIME'
Or:
ulf#kalla:~(0)(venv)$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> #Use mx.DateTime instead of pythons datetime, for compability reasons.
... psycopg2.extensions.register_type(psycopg2._psycopg.MXDATETIME)
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
AttributeError: 'module' object has no attribute 'MXDATETIME'
>>>
It seems that the installed version of psycopg2 lacks the mx-support.
How could I fix this?
You will probably need to build psycopg2 on your own, download the tar.gz, unzip, and then find the setup.cfg file, modify the mx_include parameter to be /lib/python2.7/site-packages/mx/DateTime/mxDateTime and then
python setup.py build_ext install

Manage python packages in Sublime text 3

Working with Ubuntu 14.04
How to tell Sublime text 3 and SublimeREPL where to look for the python packages?
From my terminal, pip list returns a list with many python packages like that:
numexpr (2.2.2)
numpy (1.8.2)
oauthlib (0.6.1)
oneconf (0.3.7)
openpyxl (2.2.5)
PAM (0.4.2)
pandas (0.16.2)
However, inside Sublime text 3, on the console:
>>> import openpyxl
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'openpyxl'
>>> import pandas
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'pandas'
>>> import numpy
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'numpy'
From the SulbimeREPL console:
Python 3.3.6 (default, Jan 28 2015, 17:27:09)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'pandas'
>>> import openpyxl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'openpyxl'
So, I assume that something needs to be set up.
You need to point SublimeRepl to the right interpreter.
Add to Settings -> Package Settings -> SublimeREPL -> Settings - User
{
"default_extend_env": {"PATH": "{PATH}:/usr/lib/python2.7"}
}
try this
python3 -m pip install --user openpyxl

Python's logging module misses "captureWarnings" function

Python's standard logging module is supposed to contain a useful captureWarnings function that allows integration between the logging and the warnings modules. However, it seems that my installation misses this function:
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> logging.captureWarnings
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'captureWarnings'
>>> import logging.captureWarnings
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named captureWarnings
>>> import warnings
>>> import logging.captureWarnings
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named captureWarnings
>>>
What am I doing wrong?
Unfortunately, there is no such method in Python 2.6.5's logging module. You need Python 2.7.

Categories

Resources