0

my python script uses pyodbc module. When I create setup.py script it failed to compile and throws the error:

 raise ImportError, "No module named " + qname
portError: No module named pyodbc

What is wrong with my setup.py script:

from distutils.core import setup
import py2exe

setup(
    console=['accession.py'],
    options={
        'py2exe': {
            'includes': 'pyodbc'
            }
        }
    )

Thanks in advance P.S. Sorry ... but I was wrong in my comments: 1. I do have 2 Python installation and I deleted one i.e. ipython and I have only Python 2.7 now 2. I do have pyodbc installed because I could use it when I run just 'plain' python script ( without py2exe) 3. I could check that it's installed like this:

yolk -l bottle - 0.12.7 - active pip 1.5.6 has no metadata py2exe - 0.6.10 - active pyodbc - 3.0.7 - active What else could be the problem? Thanks again

susja
  • 311
  • 3
  • 12
  • 33
  • Do you actually have `pyodbc` installed? (And is it possible that you have two different Python installations, one of which has `pyodbc` installed, while the other doesn't?) – abarnert Aug 11 '14 at 01:37
  • hi abameret, you are correct: I have 2 Python installations: ipython and Python 2.7. I just checked that 2.7 has pyodbc but ipython does not. I did my development using 2.7 and used py2exe using 2.7 as well. What would you recommend me to do to fix it?, Thanks – susja Aug 11 '14 at 13:08
  • IPython isn't a separate installation, it's a package that installs into your existing Python installation. I mean having two different Python directories (like `C:\Python27` and `D:\Python27`), each with their own Python.exe, site-packages folder, etc. – abarnert Aug 11 '14 at 17:55
  • - a artery, in my case it was 2 different installations in 2 different directories. ipython did not have pyodbc and it was first in system path. After I fixed the path I did not have the issue with odbc because my program started to use only Python 2.7 which had that module. Thanks again for heads up – susja Aug 12 '14 at 21:27
  • 1
    This question appears to be off-topic because it is caused by confusion between two separate Python installations. – abarnert Aug 12 '14 at 22:27
  • 1
    I think it's reasonable to close this as you asked (although I had a hard time coming up with a close reason). But don't post a request for closing as an answer. Only post answers as answers. If you don't have enough rep to close your own question, post a _comment_ asking others to do it (or flag it if you think it needs a mod's attention, but usually it doesn't). – abarnert Aug 12 '14 at 22:28

2 Answers2

0

You are saying that your python script uses pyodbc module, but I am not sure if you have properly installed it. Try pip install pyodbc or pip install https://pyodbc.googlecode.com/files/pyodbc-3.0.6.zip to install this module if you do not yet have it installed.

warship
  • 2,924
  • 6
  • 39
  • 65
  • -XYZ927 After I've put Python 2.7 in front in PATH variable I did not have an issue to compile it. The other issue is that my program is using Bottle and along with 'main' python script it uses 2 template files .tpl and I don't know how to include it in setup.py. Likely will need to open another ticket for it. what do you think? and thanks anyway – susja Aug 11 '14 at 13:54
  • Sorry for causing the noise. After I installed pyodbc again I don't have the issue any more. Still not clear why it's so flaky and had to install it again and now it looks like this: >yolk -l pip 1.5.6 has no metadata py2exe - 0.6.10 - active pyodbc - 3.0.7 - non-active pyodbc - 3.0.7 - non-active pyodbc - 3.0.7 - active pyodbc - 3.0.7 - active setuptools 5.4.1 has no metadata – susja Aug 11 '14 at 18:10
  • So did you get it to work using one of those two install commands I gave? Let me know if there are any other issues. – warship Aug 11 '14 at 18:56
  • Hi. I did not have to install the module. It was already there and I had only to use 'right' Python. Now I do not have problem with that module anymore. Thanks – susja Aug 12 '14 at 21:30
0

setup.py code:

from distutils.core import setup
import py2exe

setup(
    console=['yourfile.py'],
    options = { "py2exe": { "includes": "decimal, datetime" } }
)
rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156