psycopg2 installation problem on OSX Lion - installation

I used PIP to install psycopg2 on OSX Lion. But when I try to import from python I get the following errors:
Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/psycopg2/__init__.py", line 67, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: dlopen(/Library/Python/2.7/site-packages/psycopg2/_psycopg.so, 2): Symbol not found: _PQbackendPID
Referenced from: /Library/Python/2.7/site-packages/psycopg2/_psycopg.so
Expected in: flat namespace
in /Library/Python/2.7/site-packages/psycopg2/_psycopg.so
>>>
Does anyone know how to fix this?
Thanks!
Mosko

Step 1.
Install Mac Ports ( www.macports.org ) using the Lion dmg.
Step 2.
sudo port install postgresql91
Step 3.
export PATH=/opt/local/lib/postgresql91/bin:$PATH
Step 4.
pip install psycopg2
if in a virtualenv environment or
sudo port install psycopg2
if not.

Related

Installing mariadb 1.1.3 package on Python

I am having some issues installing mariadb package on python 3.8 using pip3.
I tried to import mariadb library directly on my terminal using:
(scrap_venv) apnow#web:/var/sas/scrap$ python
Python 3.8.10 (default, Jun 22 2022, 20:18:18)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mariadb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/var/sas/scrap_venv/lib/python3.8/site-packages/mariadb/__init__.py", line 6, in <module>
from ._mariadb import (
ModuleNotFoundError: No module named 'mariadb._mariadb'
>>>
But it shows that the module is not found
I get this output if I launch pip3 show mariadb
Name: mariadb
Version: 1.1.3
Summary: Python MariaDB extension
Home-page: https://www.github.com/mariadb-corporation/mariadb-connector-python
Author: Georg Richter
Author-email:
License: LGPL 2.1
Location: /var/sas/scrap_venv/lib/python3.8/site-packages
Requires:
Required-by:
Any idea?
All best,
Apnow

Python 3.6 - Tensorflow DLL load failed when importing tensorflow

I installed Tensorflow on my command prompt using pip3 on Python 3.6 using:
pip3 install tensorflow==1.5
When checking if I could import tensorflow off the terminal using Python I got the following error message:
Python 3.6.0rc2 (v3.6.0rc2:800a67f7806d, Dec 16 2016, 23:22:07) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\{User}\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\{User}\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\Users\{User}\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
File "C:\Users\{User}\AppData\Local\Programs\Python\Python36\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.
What exactly is missing from the DLL?
Are there any issues when installing? Also, why are you installing tensorflow 1.5 when 1.9 is available? I would first try pip uninstall tensorflow and then pip install tensorflow. If you still have issues I would try going here to download the .whl file and then you can do pip install [whatever the filename is].whl. Directly installing these .whl files has solved many a problem for me.
To answer your question, it looks like you are missing descriptor.py from google protobuf. You could try downloading that and moving descriptor.py directly, but my guess is if it can't find one file it's probably missing other things as well.
Looking at other problems with tensorflow imports, it looks like the problem is compatibility with python 3.6 having a divergent path with pip, however it looks like this was solved at some point in the last year. If you're still stuck, of course try upgrading pip, python, and tensorflow; then try downgrading to python 3.5 to see if that works. Best of luck!
Change the protobuf version to pip install protobuf==3.6.0

Tensorflow install on Windows with anaconda and no internet connection

I can not install Tensorflow on Windows because there in no internet connection based on commpany's security policy.
I just installed anaconda and python by transmiting files with intranet.
Please let me know how to install that with no internet connection.
==========================================================================
In addition, when I used the below command after installing tensorflow, I found
other problems..
Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Daisy\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\Daisy\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 63, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\Users\Daisy\Anaconda3\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
ImportError: No module named 'google'
I don't know how to solve this one.
If you can download the whl file and transfer it to your workstation, then you can run:
pip.exe install --upgrade --no-deps <tensorflow whl file name>
This should avoid trying to connect to download tensorflow dependencies, as anaconda already has most of these.

python 2.7 OSX 10.10 package problems

I'm using :
mac osx 10.10.1
Yesterday I started to get errors using same packages that I normally use.
After few hrs I decided to remove python from my mac
I installed python again following this instructions:
http://docs.python-guide.org/en/latest/starting/install/osx/#install-osx
(i a nut shell I installed python 2.7 using HomeBrew)
from the shell:
$python
Python 2.7.8 (default, Oct 19 2014, 16:02:00)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.54)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
from the shell:
$ which python
/usr/local/bin/python
from the shell:
$ which -a python
/usr/local/bin/python
/usr/local/bin/python
I installed pip
I installed few pkgs using $ pip install command
when I try to just import openpyxl
I'm getting this:
import openpyxl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/openpyxl/__init__.py", line 27, in <module>
from openpyxl.workbook import Workbook
File "/usr/local/lib/python2.7/site-packages/openpyxl/workbook/__init__.py", line 25, in <module>
from .workbook import *
File "/usr/local/lib/python2.7/site-packages/openpyxl/workbook/workbook.py", line 11, in <module>
import threading
File
"/usr/local/Cellar/python/2.7.8_2/Frameworks/
Python.framework/Versions/2.7/lib/python2.7/threading.py",
line 14, in <module>
from time import time as _time, sleep as _sleep
ImportError: cannot import name time
please can you help me out?
thanks
d
additional info:
meanwhile I tried to do same thing else to fix the problem
(I didn't fix it)
Basically I installed virtualenv
I created a basic virtual env
I have a new folder with python and all the pkgs
(venv_002)danielepemys-MacBook-Pro:my_python_virtualenv danielepemy$ which python
/Users/danielepemy/my_python_virtualenv/venv_002/bin/python
everything looks fine, python works, pip works the pkgs are listed in the virtual env
(venv_002)danielepemys-MacBook-Pro:my_python_virtualenv danielepemy$ pip list
pip (1.5.6)
setuptools (3.6)
wsgiref (0.1.2)
XlsxWriter (0.6.4)
when I run a simple test script with XlsxWriter I get:
python ..//internet_speed_test_002.py
Traceback (most recent call last):
File "..//internet_speed_test_002.py", line 28, in <module>
excel_file.close()
File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/workbook.py", line 286, in close
self._store_workbook()
File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/workbook.py", line 509, in _store_workbook
xml_files = packager._create_package()
File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/packager.py", line 142, in _create_package
self._write_core_file()
File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/packager.py", line 325, in _write_core_file
core._assemble_xml_file()
File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/core.py", line 57, in _assemble_xml_file
self._write_dcterms_created()
File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/core.py", line 122, in _write_dcterms_created
date = self._localtime_to_iso8601_date(date)
File "/Users/danielepemy/my_python_virtualenv/venv_002/lib/python2.7/site-packages/xlsxwriter/core.py", line 76, in _localtime_to_iso8601_date
return date.strftime("%Y-%m-%dT%H:%M:%SZ")
AttributeError: 'module' object has no attribute 'struct_time'
Do you have any files called time.py or time.pyc in your current directory? If so, rename or delete them (.pyc files can simply be deleted).

Correct way to install scikit-learn on OS-X using port

I'm tying to install scikit-learn using port on OS-X. Any idea what I'm missing here.
port version
Version: 2.1.3
OS-X
10.8.2 Build 12C60
Xcode
Version 3.2.5 (1760)
Python
Python 2.7.2 (default, Jun 20 2012, 16:23:33)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
command to install scikit-learn
sudo port install py27-scikit-learn
---> Computing dependencies for py27-scikit-learn
---> Cleaning py27-scikit-learn
---> Scanning binaries for linking errors: 100.0%
---> No broken files found.
However, looks like it's not installed or configured properly. What am I missing here ?
>>> import sklearn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named sklearn
>>> from sklearn import cluster, covariance, manifold
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named sklearn
>>>
I moved to Homebrew and everything after that was easy.

Resources