I am trying to pip install
the MySQL-python
package, but I get an ImportError
.
我正在尝试安装MySQL-python包,但是我得到了一个ImportError。
Jans-MacBook-Pro:~ jan$ /Library/Frameworks/Python.framework/Versions/3.3/bin/pip-3.3 install MySQL-python
Downloading/unpacking MySQL-python
Running setup.py egg_info for package MySQL-python
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/var/folders/lf/myf7bjr57_jg7_5c4014bh640000gn/T/pip-build/MySQL-python/setup.py", line 14, in <module>
from setup_posix import get_config
File "./setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/var/folders/lf/myf7bjr57_jg7_5c4014bh640000gn/T/pip-build/MySQL-python/setup.py", line 14, in <module>
from setup_posix import get_config
File "./setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /var/folders/lf/myf7bjr57_jg7_5c4014bh640000gn/T/pip-build/MySQL-python
Storing complete log in /Users/jan/.pip/pip.log
Jans-MacBook-Pro:~ jan$
Any ideas?
什么好主意吗?
14 个解决方案
#1
194
In Python 3, ConfigParser
has been renamed to configparser
for PEP 8 compliance. It looks like the package you are installing does not support Python 3.
在Python 3中,为了符合PEP 8的要求,ConfigParser被重命名为ConfigParser。看起来您正在安装的包不支持Python 3。
#2
289
You can instead use the mysqlclient
package as a drop-in replacement for MySQL-python. It is a fork of MySQL-python
with added support for Python 3.
您可以使用mysqlclient包作为MySQL-python的下拉替代。它是MySQL-python的一个分支,增加了对Python 3的支持。
I had luck with simply
我的运气很简单
pip install mysqlclient
in my python3.4 virtualenv after
在后面的python3.4中
sudo apt-get install python3-dev libmysqlclient-dev
which is obviously specific to ubuntu/debian, but I just wanted to share my success :)
这显然是ubuntu/debian特有的,但我只想分享我的成功:)
#3
7
Here is a code that should work in both Python 2.x and 3.x
下面的代码应该在Python 2中都可以使用。倍和3.倍
Obviously you will need the six
module, but it's almost impossible to write modules that work in both versions without six.
显然,您将需要6个模块,但是如果没有6个,几乎不可能编写在两个版本中都能工作的模块。
try:
import configparser
except:
from six.moves import configparser
#4
6
MySQL-python is not supported on python3 instead of this you can use mysqlclient
python不支持MySQL-python,而可以使用mysqlclient
If you are on fedora/centos/Red Hat
install following package
如果您正在安装fedora/centos/Red Hat安装,请安装以下包
yum install python3-devel
- yum安装python3-devel
pip install mysqlclient
- pip安装mysqlclient
#5
4
If you are using CentOS, then you need to use
如果您正在使用CentOS,那么您需要使用
yum install python34-devel.x86_64
- yum安装python34-devel.x86_64
yum groupinstall -y 'development tools'
- 百胜集团-y“开发工具”
pip3 install mysql-connector
- pip3安装mysql-connector
pip install mysqlclient
- pip安装mysqlclient
#6
2
Compatibility of Python 2/3 for configparser
can be solved simply by six
library
对于configparser, Python 2/3的兼容性可以简单地通过六个库来解决。
from six.moves import configparser
#7
1
pip install configparser
sudo cp /usr/lib/python3.6/configparser.py /usr/lib/python3.6/ConfigParser.py
Then try to install the MYSQL-python again. That Worked for me
然后再尝试安装MYSQL-python。适合我自己的
#8
1
I got further with Valeres answer:
我得到了更深入的回答:
pip install configparser sudo cp /usr/lib/python3.6/configparser.py /usr/lib/python3.6/ConfigParser.py Then try to install the MYSQL-python again. That Worked for me
pip安装configparser sudo cp /usr/lib/python3.6/configparser。py /usr/lib/python3.6/ConfigParser。然后再次尝试安装MYSQL-python。适合我自己的
I would suggest to link the file instead of copy it. It is save to update. I linked the file to /usr/lib/python3/
directory.
我建议链接这个文件,而不是复制它。保存为更新。我将文件链接到/usr/lib/python3/目录。
#9
0
how about checking the version of Python you are using first.
先检查一下您正在使用的Python版本。
import six
if six.PY2:
import ConfigParser as configparser
else:
import configparser
#10
0
I run kali linux- Rolling and I came across this problem ,when I tried running cupp.py in the terminal, after updating to python 3.6.0. After some research and trial I found that changing ConfigParser
to configparser
worked for me but then I came across another issue.
我运行kali linux- Rolling,当我尝试运行cupp时遇到了这个问题。py在终端,更新到python 3.6.0之后。经过一些研究和尝试,我发现将ConfigParser改成ConfigParser对我来说是有用的,但之后我又遇到了另一个问题。
config = configparser.configparser() AttributeError: module 'configparser' has no attribute 'configparser'
config = config .configparser() AttributeError:模块‘configparser’没有属性‘configparser’
After a bit more research I realised that for python 3 ConfigParser
is changed to configparser
but note that it has an attribute ConfigParser()
.
在进一步研究之后,我意识到,对于python 3 ConfigParser,它被改为ConfigParser,但是请注意它有一个属性ConfigParser()。
#11
0
Try this solution which worked fine for me.
试试这个对我很有效的方法。
Basically it's to reinstall/upgrade to latest version of mysql from brew, and then installing mysqlclient
or MySQL-Python
from global pip3
instead of virtualenv pip3
.
基本上,它是从brew重新安装/升级到最新版本的mysql,然后从global pip3而不是virtualenv pip3安装mysqlclient或mysql - python。
Then accessing the virtualenv
and successfully install mysqlclient
or MySQL-Python
.
然后访问virtualenv并成功安装mysqlclient或MySQL-Python。
#12
-2
Kindly to see what is /usr/bin/python
pointing to
请看看/usr/bin/python指向什么
if it is pointing to python3 or higher
change to python2.7
如果它指向python3或更高的值,那么它就会变成python2.7
This should solve the issue.
这应该能解决这个问题。
I was getting install error for all the python packages. Abe Karplus's solution & discussion gave me the hint as to what could be the problem. Then I recalled that I had manually changed the /usr/bin/python
from python2.7
to /usr/bin/python3.5
, which actually was causing the issue. Once I reverted
the same. It got solved.
我得到了所有python包的安装错误。Abe Karplus的解决方案和讨论给了我一些提示。然后我回忆说,我手动地将/usr/bin/python从python2.7更改为/usr/bin/python3.5,这实际上导致了这个问题。有一次我又恢复了原来的样子。它被解决了。
#13
-2
This worked for me
这为我工作
cp /usr/local/lib/python3.5/configparser.py /usr/local/lib/python3.5/ConfigParser.py
#14
-2
This worked for me.
这为我工作。
from ConfigParser import ConfigParser
从ConfigParser进口ConfigParser
#1
194
In Python 3, ConfigParser
has been renamed to configparser
for PEP 8 compliance. It looks like the package you are installing does not support Python 3.
在Python 3中,为了符合PEP 8的要求,ConfigParser被重命名为ConfigParser。看起来您正在安装的包不支持Python 3。
#2
289
You can instead use the mysqlclient
package as a drop-in replacement for MySQL-python. It is a fork of MySQL-python
with added support for Python 3.
您可以使用mysqlclient包作为MySQL-python的下拉替代。它是MySQL-python的一个分支,增加了对Python 3的支持。
I had luck with simply
我的运气很简单
pip install mysqlclient
in my python3.4 virtualenv after
在后面的python3.4中
sudo apt-get install python3-dev libmysqlclient-dev
which is obviously specific to ubuntu/debian, but I just wanted to share my success :)
这显然是ubuntu/debian特有的,但我只想分享我的成功:)
#3
7
Here is a code that should work in both Python 2.x and 3.x
下面的代码应该在Python 2中都可以使用。倍和3.倍
Obviously you will need the six
module, but it's almost impossible to write modules that work in both versions without six.
显然,您将需要6个模块,但是如果没有6个,几乎不可能编写在两个版本中都能工作的模块。
try:
import configparser
except:
from six.moves import configparser
#4
6
MySQL-python is not supported on python3 instead of this you can use mysqlclient
python不支持MySQL-python,而可以使用mysqlclient
If you are on fedora/centos/Red Hat
install following package
如果您正在安装fedora/centos/Red Hat安装,请安装以下包
yum install python3-devel
- yum安装python3-devel
pip install mysqlclient
- pip安装mysqlclient
#5
4
If you are using CentOS, then you need to use
如果您正在使用CentOS,那么您需要使用
yum install python34-devel.x86_64
- yum安装python34-devel.x86_64
yum groupinstall -y 'development tools'
- 百胜集团-y“开发工具”
pip3 install mysql-connector
- pip3安装mysql-connector
pip install mysqlclient
- pip安装mysqlclient
#6
2
Compatibility of Python 2/3 for configparser
can be solved simply by six
library
对于configparser, Python 2/3的兼容性可以简单地通过六个库来解决。
from six.moves import configparser
#7
1
pip install configparser
sudo cp /usr/lib/python3.6/configparser.py /usr/lib/python3.6/ConfigParser.py
Then try to install the MYSQL-python again. That Worked for me
然后再尝试安装MYSQL-python。适合我自己的
#8
1
I got further with Valeres answer:
我得到了更深入的回答:
pip install configparser sudo cp /usr/lib/python3.6/configparser.py /usr/lib/python3.6/ConfigParser.py Then try to install the MYSQL-python again. That Worked for me
pip安装configparser sudo cp /usr/lib/python3.6/configparser。py /usr/lib/python3.6/ConfigParser。然后再次尝试安装MYSQL-python。适合我自己的
I would suggest to link the file instead of copy it. It is save to update. I linked the file to /usr/lib/python3/
directory.
我建议链接这个文件,而不是复制它。保存为更新。我将文件链接到/usr/lib/python3/目录。
#9
0
how about checking the version of Python you are using first.
先检查一下您正在使用的Python版本。
import six
if six.PY2:
import ConfigParser as configparser
else:
import configparser
#10
0
I run kali linux- Rolling and I came across this problem ,when I tried running cupp.py in the terminal, after updating to python 3.6.0. After some research and trial I found that changing ConfigParser
to configparser
worked for me but then I came across another issue.
我运行kali linux- Rolling,当我尝试运行cupp时遇到了这个问题。py在终端,更新到python 3.6.0之后。经过一些研究和尝试,我发现将ConfigParser改成ConfigParser对我来说是有用的,但之后我又遇到了另一个问题。
config = configparser.configparser() AttributeError: module 'configparser' has no attribute 'configparser'
config = config .configparser() AttributeError:模块‘configparser’没有属性‘configparser’
After a bit more research I realised that for python 3 ConfigParser
is changed to configparser
but note that it has an attribute ConfigParser()
.
在进一步研究之后,我意识到,对于python 3 ConfigParser,它被改为ConfigParser,但是请注意它有一个属性ConfigParser()。
#11
0
Try this solution which worked fine for me.
试试这个对我很有效的方法。
Basically it's to reinstall/upgrade to latest version of mysql from brew, and then installing mysqlclient
or MySQL-Python
from global pip3
instead of virtualenv pip3
.
基本上,它是从brew重新安装/升级到最新版本的mysql,然后从global pip3而不是virtualenv pip3安装mysqlclient或mysql - python。
Then accessing the virtualenv
and successfully install mysqlclient
or MySQL-Python
.
然后访问virtualenv并成功安装mysqlclient或MySQL-Python。
#12
-2
Kindly to see what is /usr/bin/python
pointing to
请看看/usr/bin/python指向什么
if it is pointing to python3 or higher
change to python2.7
如果它指向python3或更高的值,那么它就会变成python2.7
This should solve the issue.
这应该能解决这个问题。
I was getting install error for all the python packages. Abe Karplus's solution & discussion gave me the hint as to what could be the problem. Then I recalled that I had manually changed the /usr/bin/python
from python2.7
to /usr/bin/python3.5
, which actually was causing the issue. Once I reverted
the same. It got solved.
我得到了所有python包的安装错误。Abe Karplus的解决方案和讨论给了我一些提示。然后我回忆说,我手动地将/usr/bin/python从python2.7更改为/usr/bin/python3.5,这实际上导致了这个问题。有一次我又恢复了原来的样子。它被解决了。
#13
-2
This worked for me
这为我工作
cp /usr/local/lib/python3.5/configparser.py /usr/local/lib/python3.5/ConfigParser.py
#14
-2
This worked for me.
这为我工作。
from ConfigParser import ConfigParser
从ConfigParser进口ConfigParser