cx_Oracle on Python2 and Python3 (Windows) - python

I have been using Python 2.7 so far on my Windows 10 machine.
Now I need to migrate towards Python3.6, but I need to run both versions in parallel for quite a while until all old scripts have been converted to Python3. From the Python3 documentation, I gather that this should be possible.
I have installed both versions, which seems to have worked, and Hello World etc. works fine on both.
Now, one of the modules I routinely work with is cx_Oracle, and even though I have installed it for Python3, it does not seem to work. (I have installed both Python and cx_Oracle from .exe installers, both are 32 bit versions, just like the old Python2.7 (under which cx_Oracle works just fine).
import cx_Oracle
gives me
ImportError: DLL load failed: Procedure not found
I have adjusted PATH to contain both Python27 and Python3, and I have rebooted.
Can anyone tell me how to solve this? Does the Python3 version need its own Oracle Instant Client or something?
Edit:
I have installed cx_Oracle cx_Oracle-6.0b1-cp36-cp36m-win32 using pip, without errors, and rebooted again.
Now cx_Oracle works from within Eclipse PyDev but when I call the same script from IDLE, I get ''ModuleNotFoundError: No module named 'cx_Oracle''' ???

Related

Python: pyodbc import module not found

I'm badly confused. I have very little problem with the Python language, but setting up Python seems to be beyond me.
I have a Windows 7 machine. I have installed the 64-bit version of Python 3.6 (more about why 64 bits later). I need the pyodbc module. I also have the 32-bit version of Python 3.5, and pyodbc is installed in its site-packages folder. The first time I tried to get pyodbc for 3.6, pip told me the requirement was already fulfilled by the version in 3.5. Then, I found the --ignore-installed option and successfully (?) installed it in my 3.6 folder.
When I open my project in PyCharm and select my 64-bit Python 3.6 as the interpreter, PyCharm shows me the pyodbc package. But when I open the file in which pyodbc is imported, PyCharm highlights the import line and tells me it can't find pyodbc. Just in case PyCharm was confused, I tried running my program from a command window, and got the same error.
Do I have to set an environment variable? I didn't have one set when I used pyodbc in a project using Python 3.5, and I had no problem.
I am trying to use 64-bit Python because a customer requires us to write into their Oracle database. They installed an ODBC driver for us, into their standard DSN list. But since we installed a 32-bit version of Python on their system, the only DSNs it can see are those installed in the 32-bit list of DSNs. If there is some easy way to use the 64-bit Oracle ODBC driver from 32-bit Python, I'd appreciate learning about it.
Thanks again.

How do I get python to import pandas?

I installed Python 3.5.1 from www.python.org. Everything works great. Except that you can't install pandas using pip (it needs visualstudio to compile, which I don't have). So I installed Anaconda (www.continuum.io/downloads). Now I can see pandas as part of the list of installed modules, but when I run python programs I still get:
ImportError: No module named 'pandas'
How do I set up my environment to use the modules from Anaconda?
Note: I have Anaconda's home directory and Library/bin on my path, as well as Python's home directory. I do not have PYTHONPATH or PYTHONHOME set, and I know I have the correct privileges to see everything.
I have successfully installed pandas for a Windows 32 bit version Python 3.4 with pre-complied code (no Visual Studio required) using the website:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyyaml
There is link for Python 3.5 pre-complied code at this site as well, but I have not tested it.
Download the code you want to a directory on your machine.
Using your Windows CMD.exe, go to your python directory and enter:
Python -w pip install "YourDirectory/pandas-0.18.1-cp35-cp35m-win32.whl"
OR
Python -w pip install "YourDirectory/pandas-0.18.1-cp35-cp35m-win_amd64.whl
Choose the version based on the version of Python you have
have, 32 bit or 64 bit.
Good Luck!
Anaconda has included one version of Python with it. You have to change your system environment path with Anaconda's instead of the former one to avoid conflict. Also, if you want to make the whole process easy, it is recommended to use PyCharm, and it will ask you to choose the Python interpreter you want.

Installing Pillow for Python on Windows

I am fairly new to Python and trying to install the Pillow package on Windows 7. I downloaded and ran the MS Windows installer Pillow-2.2.1.win-amd64-py3.3.exe from here. It appeared to install fine. If I run the simple line of code:
from PIL import Image
directly from the Python interpreter, it runs fine. A help() on PIL gives me the package contents.
But when I try to run the same line of code from within a script, I get an ImportError: No module named PIL. What am I missing?
(Note that I've been able to import sys and import MySQLdb from within scripts just fine.)
Resolved: sure, enough, I'm running Python 2.7 when I run scripts. (I think I vaguely recall having to install an older version so I could interface with MySQL.) Thank you all for pointing out that I should check the version being used.
For third-party modules for Windows, my go-to resource is Christoph Gohlke's Python Extension Packages for Windows. You can find the latest version of Pillow here. Make sure you're working with the python.org version of Python.
As far as your specific error, it's hard to tell exactly without a traceback, but make sure your script is calling the correct version of Python. If you have also installed Python 2.7, for example, your script may be calling that instead of 3.3.
In such cases I'm simply printing the sys.path at the beginning of the script in trouble and comparing it with the one from the working python interpreter. In most cases I was running the script with a different python interpreter.
In my case , I was referring to wrong pip folder.
Changed virtual environment in pycharm to point to right pip folder to solve this issue
import sys
print ( sys.path )

python installation can't find psycopg2 ImportError

I'm calling on psycopg2 with
import psycopg2
I get the std error
ImportError: No module named psycopg2
I installed my copy with macports, so I'm curious why it wouldn't work because all of the dependencies should be downloaded as well.
I don't have any experience with Postgresql, nor this module, so I don't know what could be going wrong. Fact is, another project I'm trying to get built calls upon it, so if I could avoid using this I would. :)
I'm sure that postgresql is installed, but that has little to do with the fact that my installation can't find psycopg2. Any suggestinos would be appreciated.
$ which python
reveals
/Library/Frameworks/Python.framework/Versions/Current/bin/python
and
$ python --version
reveals
Python 2.7.3 -- EPD_free 7.3-2 (32-bit)
I don't necessarily want the version of EPD_free, but I had to install it for (somewhat) unrelated reasons.
MacPorts installs its own version of Python alongside Apple's version. You can manage the active version of Python (the one that gets run when you type in python at the command line or by /usr/bin/env) by using the port select command. See this question.

Problem installing MySQLdb on windows - Can't find python

I'm trying to install the module mySQLdb on a windows vista 64 (amd) machine.
I've installed python on a different folder other than suggested by Python installer.
When I try to install the .exe mySQLdb installer, it can't find python 2.5 and it halts the installation.
Is there anyway to supply the installer with the correct python location (even thou the registry and path are right)?
did you use an egg?
if so, python might not be able to find it.
import os,sys
os.environ['PYTHON_EGG_CACHE'] = 'C:/temp'
sys.path.append('C:/path/to/MySQLdb.egg')

Categories