How do I handle an UnresolvedImport Eclipse (Python)

后端 未结 8 2451
悲&欢浪女
悲&欢浪女 2021-02-20 04:41

When I write import MySQLdb in Eclipse using the PyDev plugin, I get an unresolved import. However, the program runs without error. I can add an annotation to get

8条回答
  •  庸人自扰
    2021-02-20 05:22

    I had a similar issue and the following is what I did to solve my issue. I have a Windows 8 Machine, Python 2.7 installed and running my stuff through eclipse.

    Some Background:

    When I did an easy install it tries to install MySQL-python 1.2.5 which failed with an error: Unable to find vcvarsall.bat. I did an easy_install of pip and tried the pip install which also failed with a similar error. They both reference vcvarsall.bat which is something to do with visual studio, since I don't have visual studio on my machine, it left me looking for a different solution, which I share below.

    The Solution:

    1. Reinstall python 2.7.8 from 2.7.8 from https://www.python.org/download this will add any missing registry settings, which is required by the next install.
    2. Install 1.2.4 from http://pypi.python.org/pypi/MySQL-python/1.2.4

    After I did both of those installs, I reopened eclipse and got a prompt to update the paths of eclipse which I accepted, after that I was able to query my MySQL db.

提交回复
热议问题