0

所以我尝试了多种方法来安装mysql-python和MYSQLdb。我尝试通过此链接下载:https ://sourceforge.net/projects/mysql-python/然后当我运行时python setup.py install出现以下错误:

Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.28.tar.gz
Traceback (most recent call last):
  File "/Users/Jackson/Google Drive/CS520/HW/MySQL-python-1.2.4b4/distribute_setup.py", line 143, in use_setuptools
    raise ImportError
ImportError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "setup.py", line 7, in <module>
    use_setuptools()
  File "/Users/Jackson/Google Drive/CS520/HW/MySQL-python-1.2.4b4/distribute_setup.py", line 145, in use_setuptools
    return _do_download(version, download_base, to_dir, download_delay)
  File "/Users/Jackson/Google Drive/CS520/HW/MySQL-python-1.2.4b4/distribute_setup.py", line 124, in _do_download
    to_dir, download_delay)
  File "/Users/Jackson/Google Drive/CS520/HW/MySQL-python-1.2.4b4/distribute_setup.py", line 194, in download_setuptools
    src = urlopen(url)
  File "/Users/Jackson/anaconda3/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/Users/Jackson/anaconda3/lib/python3.6/urllib/request.py", line 532, in open
    response = meth(req, response)
  File "/Users/Jackson/anaconda3/lib/python3.6/urllib/request.py", line 642, in http_response
    'http', request, response, code, msg, hdrs)
  File "/Users/Jackson/anaconda3/lib/python3.6/urllib/request.py", line 570, in error
    return self._call_chain(*args)
  File "/Users/Jackson/anaconda3/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/Users/Jackson/anaconda3/lib/python3.6/urllib/request.py", line 650, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: SSL is required

我找不到有效的解决方案,所以我尝试pip install mysql-python了,然后我得到以下

    Traceback (most recent call last):
  File "setup.py", line 6, in <module>
    req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
NameError: name 'url' is not defined
Jacksons-MacBook-Pro:MySQL-python-1.2.4b4 Jackson$ pip install mysql-python
Collecting mysql-python
  Using cached MySQL-python-1.2.5.zip
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/tmp/pip-build-kdgbz3qe/mysql-python/setup.py", line 13, in <module>
        from setup_posix import get_config
      File "/private/tmp/pip-build-kdgbz3qe/mysql-python/setup_posix.py", line 2, in <module>
        from ConfigParser import SafeConfigParser
    ModuleNotFoundError: No module named 'ConfigParser'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-kdgbz3qe/mysql-python/

当我查看这个问题时,我尝试运行:

pip install --upgrade setuptools
pip install ez_setup
easy_install -U setuptools

没有问题,但是当我尝试重新运行命令时,pip install mysql-python我得到与以前相同的错误。我尝试下载 mysqlclient 和 mysql/python 连接器,但没有任何效果。我只想修复尝试安装 mysql-python、mysqlclient、MYSQLdb、mysql/python 连接器或任何可以实际工作的东西。我已经安装并运行了 mysql 以及 Sequel Pro。

4

2 回答 2

1

我可以通过运行@Devstr 和@jsteele 的组合来解决这个问题。我意识到从python连接到mysql的python模块不是mysql```mysql-connector`。

按着这些次序:

brew cask install mysql-connector-python
pip search mysql-connector | grep --color mysql-connector-python
pip install mysql-connector-python-rf

然后在python中:

import mysql.connector
...

发现了一些有用的信息:MySQLdb、mysqlclient 和 MySQL 连接器/Python 有什么区别?

于 2019-09-12T08:40:22.950 回答
-1

也许使用冲泡?

brew cask install mysql-connector-python

https://apple.stackexchange.com/questions/130324/how-to-install-mysql-utilities-using-brew-or-brew-cask#136180

于 2018-02-23T23:46:05.963 回答