Python pip unable to locate pyodbc

前端 未结 6 488
不思量自难忘°
不思量自难忘° 2020-12-24 06:51

Using virtualenv and just trying to install pyodbc. All resources I can find claim this should be extremely straightforward. After all the basic installs of MySQL, etc., jus

相关标签:
6条回答
  • 2020-12-24 06:55

    There is an "easier" way to install pyodbc on windows in a virualenv using easy_install:

    • download latest pyodbc installer for windows
    • activate your virtualenv
    • easy_install pyodbc-3.0.7.win32-py2.7.exe

    as used for pywin32 see: How can I use pywin32 with a virtualenv without having to include the host environment's site-packages folder?

    0 讨论(0)
  • 2020-12-24 06:58

    Both --allow-unverified and --allow-external take package name as an argument.

    From pip help install:
    --allow-external <package>   Allow the installation of a package even if it
                                 is externally hosted
    --allow-unverified <package> Allow the installation of a package even if it 
                                 is hosted in an insecure and unverifiable way
    
    • --allow-external requires an argument (name of th external to allow).
    • Same goes for --allow-unverified too .
    • With pip install --allow-external pyodbc, you are allowing the external called pyodbc
    • pip install --allow-external pyodbc pydodbc is what you need, first pyodbc allows that external, second one actually tells pip which package to install.

      From pip help install: --allow-external Allow the installation of a package even if it is externally hosted --allow-unverified Allow the installation of a package even if it is hosted in an insecure and unverifiable way

    So your usage should be

    pip install <pkg> --allow-unverified <pkg> --allow-external <pkg>

    or the little confusing:

    pip install --allow-unverified <pkg> --allow-external <pkg> <pkg>

    DO NOT use --allow-all-external when you just want to allow one and not ALL. It kills the whole purpose of putting in the security check.

    0 讨论(0)
  • 2020-12-24 07:00

    Running pip install --allow-external pyodbc --allow-unverified pyodbc pyodbc will work if the PyPI directory structure is correct.

    Based on the pip.log output when I originally posted this answer, I think that package's website directory structure was broken. You can always work around this type of problem by specifying the URL of the package like pip install https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/pyodbc/pyodbc-3.0.7.zip, links for different versions are described here.

    0 讨论(0)
  • 2020-12-24 07:08

    I just tried installing pyodbc as well and hit the same wall. I think the problem you and I both hit is that --allow-external consumes the next argument as well. So you actually need to write:

    sudo pip install --allow-external pyodbc pyodbc
    

    I then hit another error about unverified sources so that command that actually worked for me was:

    sudo pip install --allow-external pyodbc --allow-unverified pyodbc pyodbc
    

    Note that once that was done the permissions on the installed files prevented normal users from access pyodbc. So I went in manually adjusted the permissions on all installed packages (seemed easier than finding just the files needed by pyodbc).

    cd /usr/local/lib/python2.7/
    chmod -R o=g dist-packages
    

    As per the suggestion of EMS I have added an issue to the Pip bug tracker. It can be found at:

    https://github.com/pypa/pip/issues/1893

    0 讨论(0)
  • 2020-12-24 07:13

    FWIW, on ms windows anything other than installing the binary (windows install) for me was cumbersome in a windows/cygwin hybrid environment.

    I opted to use pypyodbc as it's pure python and didn't require any changes for my windows/linux development. It can be seen as an almost drop-in replacement for pyodbc with no compilation needed, and of course can be installed easily with pip install pypyodbc.

    0 讨论(0)
  • 2020-12-24 07:16

    I had success when installed with

    sudo pip install --allow-external pyodbc --allow-unverified pyodbc pyodbc
    

    However, I also needed the unixodbc-dev package in order for pyodbc to actually compile.

    0 讨论(0)
提交回复
热议问题