I am having issiues installing cx_oracle. I have installed oracle instantclient and cx_oracle oracle packages ones installed i am getting this error while importing cx_oracle. i am running ubuntu 11.10 as host.
import cx_Oracle
Traceback (most recent call last):
File "<console>", line 1, in <module>
ImportError: /usr/lib/python2.7/dist-packages/cx_Oracle.so: undefined symbol:PyUnicodeUCS2_AsEncodedString
any one have any idea how to resolve this issue
cheers
Most probably your Python install uses another unicode format (ucs4) and cx_oracle was compiled with ucs2.
You can install cx_Oracle 5.0.4 with the unicode flag. That worked for me but there is some bug: strange Oracle error: "invalid format text"
Or compile the latest cx_oracle yourself.
http://mrpolo.com.ve/?p=178 (its some language i don't know but it helped)
I addition to #froZieglers answer. When I came along the cx_Oracle page there was no "...Unicode..."-Variant to download anymore. Luckily compiling it myself from source was not a big a hassle then I expected.
Here a summary about what I did (Ubuntu 12.04 LTS, 64bit):
install the proper Oracle XE client rpm with alien (11g, 64bit, etc...)
it installs th /u01/..., I had to adjust .profile too, of course.
download cx_Oracle source-tar, untar, cd into
I did the ln -s command on the so-lib on Oracle, as said in BUILD text file
Install Python headers with sudo aptitude install python-dev
Compile with python setup.py build
Install with sudo python setup.by install
First try failed with distutils.errors.DistutilsSetupError: cannot locate an Oracle software installation
patched setup.py with setting userOracleHome = "/u01/app/oracle/product/11.2.0/xe" after os.getenv("ORACLE_HOME")
sudo python setup.by install then worked
Check with python -c 'import cx_Oracle' succeeded.
Related
I'm using the "import ldap" in a python code. This is on a windows 10 machine.
I installed the python-ldap module
pip3 install python-ldap
Installed the dependencies based on the instructions at Python Can't install packages
Also resolved all the pip deployment issues based on Installing python-ldap in a virtualenv on Windows
I'm now getting the following error when executing the import ldap statement. am I missing something here? Any ideas to resolve it?
thon39\site-packages\ldap\__init__.py", line 34, in <module>
import _ldap
ImportError: DLL load failed while importing _ldap: The specified module could not be found.
Visit the unofficial Python binaries page:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap
Download the appropriate WHL package for your system.
For example, if you're using Python 3.8 on an x64 system, download python_ldap‑3.3.1‑cp38‑cp38‑win_amd64.whl
(hint: do NOT download the +sasl version unless you have the Cyrus SASL code running on your system...)
Start the VirtualEnv for your project, if you're using one (C:\Users\youruser\.virtualenv\YourVirtualEnv\Scripts\activate.bat) -- if you're not, skip this step.
Then run pip3 install C:\Path\To\python_ldap_x.x.x-cpXX-cpXX-winXX.whl and this should install the Python DLL (pyd) file for you.
The python command is pip install mysql-python
The full error is _mysql.c(42): fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory
Can someone please tell me how to fix this error?
What exactly is mysql-python and how is it different from regular mysql?
Another stack overflow post suggested installing it with a setup executable, where can I find this?
I installed something called mysql python connector from here:
https://downloads.mysql.com/archives/c-c/
It installed into C:\Program Files\MySQL\MySQL Connector C 6.1
However, I cannot find mysqld executable anywhere in this folder
Does this install mysql or do I actually need to install it from the Oracle website?
This required the full MySql server installation from Oracle
mysql-python is a module built for python-2 for interfacing with the mysql server so this does not include the mysql server and there is a fork of the same module called mysqlclient for python-3.
The reason for your error is you haven't installed Visual Studio 2019 to compile the c/c++ code in the python package. If you don't want to install Visual Studio 2019 check out these Python Wheel (.whl) files according to your python version
https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python (Python 2)
https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient (Python 3)
I am using windows 8 and python 3.6.1 I've done the following command in my cmd:
pip install cryptoshop
However, when I run the following python code:
from cryptoshop import encryptfile
from cryptoshop import decryptfile
result1 = encryptfile(filename="test", passphrase="mypassphrase", algo="srp")
print(result1)
result2 = decryptfile(filename="test.cryptoshop", passphrase="mypassphrase")
print(result2)
I get the following error:
Traceback (most recent call last):
File "C:/Users/Owner/Desktop/test.py", line 1, in
from cryptoshop import encryptfile
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop__init__.py", line 26, in
from cryptoshop.cryptoshop import encryptfile
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop\cryptoshop.py", line 56, in
from ._cascade_engine import encry_decry_cascade
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop_cascade_engine.py", line 27, in
from ._nonce_engine import generate_nonce_timestamp
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop_nonce_engine.py", line 39, in
import botan
ModuleNotFoundError: No module named 'botan'
Now, I obviously know that you must install botan into python in order to use it. However, this is where I am running into an issue. I've downloaded Botan from this link as instructed:
https://github.com/randombit/botan
And then I've followed these instructions in an attempt to install Botan:
./configure.py [--prefix=/some/directory]
make
make install
However, when I type make into the command line I get an error saying there is no such command. And then when I go to run my above Python code I still get the no module Botan error. So obviously I am doing something run. How can I properly install Botan into my Python 3.6 directories so that I can use cryptoshop.
I've also attempted to do pip install Botan, as that is how I've installed so many other python libraries but that has been unsuccessful as well.
make is a linux command
According to the botan website you can use nmake as a replacement on windows ( http://wiki.c2.com/?UsingNmake ) :
On Windows
You need to have a copy of Python installed, and have both Python and
your chosen compiler in your path. Open a command shell (or the SDK
shell), and run:
$ python configure.py --cc=msvc (or --cc=gcc for MinGW) [--cpu=CPU]
$ nmake
$ botan-test.exe
$ nmake install
Botan supports the nmake replacement Jom which enables you to run
multiple build jobs in parallel.
source : https://botan.randombit.net/manual/building.html
For completeness, here's how I made it work on a Mac
Assuming you have brew installed.
brew install botan
You may need to install other functionality first:
brew install gmp
brew install mpfr
brew install mpc
Find out where botan got installed with brew info botan.
My location is /usr/local/Cellar/botan/2.6.0
In that folder, you'll find lib/python2.7/site-packages, copy the contents of this folder into your Python's installation site-packages folder.
Note 1: At the time of this writing, only python 2.7 seems to be supported, but I'm using python 3.6 and everything seems to be working.
Note 2: If the file is called botan2.py, you may need to rename it to botan.py in your python's site-packages folder.
I am unable to import the sqlite3 module in Python, version 3.5.0. Here's what I get:
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.5/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named '_sqlite3'
I know, I know, there are PLENTY of StackOverflow posts and support forums across the web where people complain about this problem, but none of the posted solutions have worked for me so far. Here's where I've been:
I also have Python 2.6.6 installed on this server, which is running CentOS 6.8 x86_64. I can open up the Python REPL and import sqlite3 just fine when using Python 2.6.6. I can also use sqlite3 from straight from bash and nothing seems awry.
This helpful question looked promising. I tried to re-configure and re-compile Python3.5 with the --enable-loadable-sqlite-extensions option, as user jammyWolf suggested. Nope, same error still occurs.
I've been using virtual environments like a good boy, but I have root access to this server. So, I was a bad boy and ran python3 as root without any virtualenvs activated. Still no luck. So I don't think it has anything to do with permissions.
I noticed that in the error message, it says No module named '_sqlite3'. This thread suggests that the underscore before the module name means that the module is an implementation detail, and isn't exposed in the API. ... I'm not sure what to make of this information, but there may be a hint somewhere in there.
Any ideas?
Falsetru is correct, I am going to go into a bit more detail for those not familiar (linux instructions). If you are getting this error, chances are you are using a version of python that was compiled without the correct headers. Here's a step by step guide to get it sorted. (Python 3.X.X instructions)
Install the required sqlite libraries
sudo apt-get install libsqlite3-dev
Uninstall python (I'm using python 3.6.5 as an example in this guide)
sudo apt-get remove python3.6
Download python from source
cd /tmp && wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
Unpack the archive
tar -xvf Python-3.6.5.tgz
Configure
cd Python-3.6.5 && ./configure
Make and install (and go make coffee while you're at it)
make && sudo make install
If you did everything correctly running "python3.6 -V" should give you your python version. Note you will have to rebuild any virtual environments you have as well.
One final caveat you may encounter.
zipimport.ZipImportError: can't decompress data; zlib not available
This happens if you don't have the following zlib library installed:
sudo apt-get install zlib1g-dev
Install sqlite-devel package which includes header, library that is required to build sqlite3 extension.
yum install sqlite-devel
NOTE: Python does not include sqlite3 library itself, but an extension module (wrapper).
I copied sqlite3.dll to this folder:
C:\Users\*****\Anaconda3\DLLs
It worked after two weeks trying everything else.
I used the article on https://github.com/nwcell/psycopg2-windows and https://bitbucket.org/topper/psycopg2-win64-py27/overview to get psycopg2 installed and working on Python2.7 and Cygwin.
The install ran fine and i see the package in the /usr/lib/python2.7/site-packages/psycopg2-2.5.3-py2.7.egg/ directory.
However the import does not work.. Any idea on this error?
Python 2.7.8 (default, Jul 25 2014, 14:04:36)
[GCC 4.8.3] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/psycopg2-2.5.3-py2.7.egg/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: No module named _psycopg
Thanks,
Manish
I was getting this exact set of messages -- but not in my local Cygwin/Babun dev environment -- I got them when I pushed to the RHEL 7 server to test there. It took two days to flush it out, and how I solved it likely doesn't apply to you. But I learned some things that probably do.
Another cause of this error is argued at great length in these bug reports (with Python and psycopg pointing fingers at each other) -- and generally not worth the read -- read on below instead:
http://bugs.python.org/issue16047
https://psycopg.lighthouseapp.com/projects/62710/tickets/201
The gist of it? Look for some updates -- it looks like they both might have made some small changes that affect this.
Anyway... this is how I installed psycopg2 in Cygwin (assuming Babun's pact installer is available):
pact install libpq-devel
pip install psycopg2
Yup, that's it! (Some envs might also require a C compiler and python*-devel.)
An alternative to installing libpq-devel is to install Windows Postgres and add the location of its pg_config file to your PATH so that pip can compile psycopg2 -- but installing libpq-devel from the Cygwin shell is cleaner and it puts its pg_config where pip can already find it.
I installed pyscopg2 from within a virtual env but that shouldn't have mattered. What might matter, however, could be one of the following:
Python version: You were using 2.7.8 (almost the latest for the time), I was using 3.4.3. Try a later version of 2.7.
psycopg2 version: You were using 2.5.3, I was using 2.6.1.
Conflicting Python installs. Check the sys.path values from within Python to make sure it looks as you would expect. This doesn't appear to be your problem according to what you posted, but I mention it because this was ultimately my problem on RHEL 7 and how Apache was loading the virtual envs. ---- (Just another note here: I ultimately resolved the RHEL problem by compiling another mod_wsgi for Python 3.4.3, as per their instructions, to match my virtual envs. The previous mod_wsgi was running under Python 2.7.5 and that version was failing to import _psycopg from a C library. Besides, I didn't want 2.7 running at all.)
Env = python 2.7.10 (cygwin distribution), Windows 7, Cygwin 64
1) pip install psycopg2 failed as I didn't have pip
debug
2) Installed pip from here: pip.pypa.io/en/stable/installing/
3) pip install psycopg2 failed due to 'no pg_config...'
4) psycopg2 installer for win (www.stickpeople.com/projects/python/win-psycopg/) failed cause I am using cygwin's python install, not the python in the machine's registry and this installer won't allow user to install anywhere else other thatn the python that is registred with Windows
(Installer succeeded, but the files were not where I needd them.)
("Copying" the files didn't work.)
5) This (https://github.com/nwcell/psycopg2-windows) pip install "worked" (gave no errors) but when I tried to import, I got the message:
"ImportError: No module named psycopg2"
6) pip uninstall psycopg2
7) Tried to pip install libpq-dev and python-dev
"Could not find a version that satisfies the requirement libpq-dev (from versions: )
No matching distribution found for libpq-dev"
8) installed Postgres & pg_config from here http://www.enterprisedb.com/products-services-training/pgdownload#windows
9) added pg_config to path
10) pip install psycopg2 now worked
11) import psycopg2 in .py file caused core dump
Stack trace:
Frame Function Args
006001A5A60 0018007261A (000FFFFE3F4, 0000000E514, 00000000000, 000FFFFDE50)
006001A5B00 00180073DD0 (00077801FD6, 00000000000, 00000000140, 00000000000)
006001A5D50 0018012EF8F (00600010540, 00000000000, 003DB05FDB0, 6FFFFF28050)
006001A6040 0018012BC70 (0000000000D, 00000000000, 00000000000, 0018013D7DA)
00000000000 0018012C139 (006001A6030, 3630303030303030, 3036303030303030, 00000
00000B)
00000000000 0018012C30C (00000000000, 10000000A8E73, 6F007000650072, 61006C0074
0072)
00000000000 00180127BFB (00000000000, 10000000A8E73, 6F007000650072, 61006C0074
0072)
00000000000 00180071169 (01000000010, 00000000000, 00000000000, 000FFFFCE00)
000FFFFAA00 00180073D11 (B64000B00630079, 00000000088, 1D17578E1C375D4, 1D17578
E16661AE)
52004F00520052 64006F00630072 (00000000088, 1D17578E1C375D4, 1D17578E16661AE, 1
D175A09055FB4F)
52004F00520052 70002E00730065 (1D17578E1C375D4, 1D17578E16661AE, 1D175A09055FB4
F, 1D175A09055FB4F)
52004F00520052 B64000B00630079 (1D17578E16661AE, 1D175A09055FB4F, 1D175A09055FB
4F, 0000000180B)
52004F00520052 00000000088 (1D175A09055FB4F, 1D175A09055FB4F, 0000000180B, 0000
0002000)
52004F00520052 1D17578E1C375D4 (1D175A09055FB4F, 0000000180B, 00000002000, 01A0
0000020)
52004F00520052 1D17578E16661AE (0000000180B, 00000002000, 01A00000020, 45001600
000000)
52004F00520052 1D175A09055FB4F (00000002000, 01A00000020, 45001600000000, 4E004
500540058)
End of stack trace (more stack frames may be present)
(The above took ~2 days.)
12) pip install pg8000 worked
13) imported pg8000 to .py file and connected to DB
(Steps 12 and 13 took ~20 minutes.)
It's mandatory to install libpq, which sometimes is not installed as part of libpq-devel. As of now, I succedded installing libpq5.
You must use Cygwin package installer to install BOTH of the two packages:
libecpg6, for psycopg2 runtime library support, without it you will get
'ImportError: No module named _psycopg' when you run your script.
libecpg-devel, for compiling psycopg2 without it you will get a lot of
such as pthread_*** errors when you install psycopg2 using pip tool.
As time goes on, those package name may be changed, but you should know what's
you deficiency.