Skip to content

IBM-DB module: ibm_db_dbi.py - syntax error on empty lines preceeded by '\' #386

Closed
@srgari

Description

@srgari

Sorry if this has beem mentioned before... I couldn't find it on a quick glance, neither did Google.

I installed ibm_db on my Windows 10 machine, with Anaconda installed, via pip install ibm_db. However, whenever I tried to import ibm_db_dbi.py, I had a syntax error.

Inspecting the code, I noticed there was an empty line on the syntax error, after a if clause, ended with '.'. Deleting the empty line resulted in another syntax error, this time in a line below, following the same pattern. I proceeded to remove all empty lines that resulted in syntax errors.

On all accounts of the code where there was a while or if clause, with a \ at the end of the line, and the next line was empty, the code would return a 'syntax error', as if the code was missing a parenthesis.

By removing the empty lines, on all these occurrences, I managed to make the code run.

Just thought it could be useful. Again, sorry if that's been mentioned before, or just an issue with me.

Activity

SabaKauser

SabaKauser commented on Apr 4, 2019

@SabaKauser
Contributor

Hello,
python regenerates this file and adds the new lines when ibm_db is installed. This problem as far as I know is seen when you build the source using python setup.py build. Having to use pip does not have this problem.
You might be loading ibm_db_dbi from the source location. cd to home or other directory and load and python would load the module from site-packages and site-packages will have the correct one.

SabaKauser

SabaKauser commented on Apr 16, 2019

@SabaKauser
Contributor

closing as question is answered.

telnoratti

telnoratti commented on Sep 6, 2019

@telnoratti

I'm having this exact issue on Windows Server 2012 R2. I am installing from pip and have tried with and without a virtualenv.

>>> import ibm_db_dbi
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\cdwinkowski\venv\lib\site-packages\ibm_db_dbi.py", line 846

    ^
SyntaxError: invalid syntax

Line 846 looks to be a new line after a \. The entire file appears to have duplicate new lines. Python version is 3.7.0 and pip version is 19.2.3.

SabaKauser

SabaKauser commented on Sep 6, 2019

@SabaKauser
Contributor

can you try latest version of python 3.7.

telnoratti

telnoratti commented on Sep 6, 2019

@telnoratti

I upgraded to 3.7.4 and reinstalled ibm_db, but I still got the same problem.

SabaKauser

SabaKauser commented on Sep 10, 2019

@SabaKauser
Contributor

I don't understand why this problem is happening only for you.
I tried on a venv from python 3.7.2, 3.7.4 and in both versions, I can see ibm_db_dbi.py getting installed correctly under site-packages that does not have extra lines after ''.

telnoratti

telnoratti commented on Sep 10, 2019

@telnoratti

I got it working, but I'm not sure I understand the cause. Uninstalling the package and reinstalling it with pip --no-cache-dir install ibm_db did it.

On closer examination it appears that this file has CRLF line endings, not true additional new lines. I ran file on the ibm_db_dbi.py file from a working system and the problem system. The working system says ibm_db_dbi.py: Python script, ASCII text executable, with CRLF line terminators, but the broken system says ibm_db_dbi.py: Python script, ASCII text executable, with CRLF, CR line terminators. Perhaps python is detecting the file doesn't use pure CRLF line endings and treats the CR character as a new line. Perhaps I hit a bug in python 3.7.0 and the wheel file stayed built in cache after I upgraded?

Thanks for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @telnoratti@SabaKauser@srgari

        Issue actions

          IBM-DB module: ibm_db_dbi.py - syntax error on empty lines preceeded by '\' · Issue #386 · ibmdb/python-ibmdb