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
Related
I am having trouble importing a library called pymssql.
I have read previous solutions regarding this issue on stack overflow. The following are the solutions that did not work:
Error importing pymssql
import pymssql Unicode DecodeError in windows 7
I am running a conda virtual environment with Python 3.7.9. The following is the output when I run python in the terminal.
Python 3.7.9 (default, Aug 31 2020, 07:22:35)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
So, this confirmed that I was using the correct Python version. Next, I tried to import a library called pymssql.
This looked like:
>>> import pymssql
This returned an error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/anaconda3/envs/conda_env/lib/python3.7/site-packages/pymssql/__init__.py", line 3, in <module>
from ._pymssql import *
File "src/pymssql/_pymssql.pyx", line 1, in init pymssql._pymssql
ImportError: dlopen(/usr/local/anaconda3/envs/conda_env/lib/python3.7/site-packages/pymssql/_mssql.cpython-37m-darwin.so, 2): Symbol not found: _iconv
Referenced from: /usr/local/anaconda3/envs/conda_env/lib/python3.7/site-packages/pymssql/_mssql.cpython-37m-darwin.so
Expected in: flat namespace
in /usr/local/anaconda3/envs/conda_env/lib/python3.7/site-packages/pymssql/_mssql.cpython-37m-darwin.so
>>>
I have tried conda install pymssql and pip install pymssql. Neither of these solved the issue.
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!
I am trying to use mlpack in python scripts. I just installed the mlpack package from source into my directory /home/glassjawed/local/ and
glassjawed#Y9Acer:~$ ls local/lib | grep mlpack
libmlpack.so
libmlpack.so.3
libmlpack.so.3.0
glassjawed#Y9Acer:~$ ls local/include/mlpack/bindings/python
get_arma_type.hpp print_defn.hpp
get_cython_type.hpp print_doc_functions.hpp
get_numpy_type_char.hpp print_doc_functions_impl.hpp
get_numpy_type.hpp print_doc.hpp
get_param.hpp print_input_processing.hpp
get_printable_param.hpp print_output_processing.hpp
get_python_type.hpp print_pyx.hpp
import_decl.hpp py_option.hpp
mlpack strip_type.hpp
print_class_defn.hpp
So mlpack is clearly installed. HOWEVER, I can't seem to run this in python because I get a module not found error.
glassjawed#Y9Acer:~$ python
Python 3.6.7 | packaged by conda-forge | (default, Nov 21 2018, 03:09:43)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>> import mlpack
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mlpack'
Why is this happening and how can I fix this? I tried everything.
`
When I try to import PYMC installed with pip, enpgk or the canopy GUI package manager, I tried all of them and without success.
Enthought Canopy Python 2.7.9 | 64-bit | (default, Jun 30 2015, 22:40:22)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-55)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/renanpc/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pymc/__init__.py", line 30, in <module>
from .CommonDeterministics import *
File "/home/renanpc/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pymc/CommonDeterministics.py", line 21, in <module>
from .utils import safe_len, stukel_logit, stukel_invlogit, logit, invlogit, value, find_element
File "/home/renanpc/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pymc/utils.py", line 14, in <module>
from . import flib
ImportError: libgfortran.so.1: cannot open shared object file: No such file or directory
I tried to install GFORTRAN with :
~$ sudo apt-get install gfortran-4.6
but I still get the same error.
(there are other questions very similar indeed, but usually the answer has to do with Anaconda and I'm using Canopy)
Any idea of what is going on ? I can import other packages.
I am going through the python tutorial and seem to be missing something very basic. The tutorial has:
>>> import site
>>> site.getusersitepackages()
'/home/user/.local/lib/python3.2/site-packages'
But I get the following:
$ python
Python 2.6.8 (unknown, Jun 9 2012, 11:30:32)
[GCC 4.5.3] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import site
>>> site.getusersitepackages()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'getusersitepackages'
As it says above, I am running Python 2.6.8 on cygwin.
Is this installation error?
According to the docs, this feature/function was added in python2.7 -- You're still on python 2.6