0

I am not quite experienced using pip. When I tried to install some packages, I had this error and had no idea what that meant. This happened to multiple packages that I tried to install. Any suggestions would be appreciated.

sudo pip install mysql-python
Password:
WARNING: The directory '/Users/yzr/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting mysql-python
  Downloading MySQL-python-1.2.5.zip (108 kB)
     |████████████████████████████████| 108 kB 2.2 MB/s 
    ERROR: Command errored out with exit status 1:
     command: /Users/yzr/opt/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-0kcqh5vw/mysql-python/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-0kcqh5vw/mysql-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/tmp/pip-install-0kcqh5vw/mysql-python/pip-egg-info
         cwd: /private/tmp/pip-install-0kcqh5vw/mysql-python/
    Complete output (7 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/tmp/pip-install-0kcqh5vw/mysql-python/setup.py", line 13, in <module>
        from setup_posix import get_config
      File "/private/tmp/pip-install-0kcqh5vw/mysql-python/setup_posix.py", line 2, in <module>
        from ConfigParser import SafeConfigParser
    ModuleNotFoundError: No module named 'ConfigParser'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
phd
  • 82,685
  • 13
  • 120
  • 165
Jim Yang
  • 177
  • 2
  • 10
  • 1
    Does this answer your question? [Python 3 ImportError: No module named 'ConfigParser'](https://stackoverflow.com/questions/14087598/python-3-importerror-no-module-named-configparser) – hoefling Feb 13 '20 at 21:21
  • As you can see `ConfigParser` module is missing, have you tried installing `ConfigParser`? – Guven Degirmenci Feb 13 '20 at 22:59

2 Answers2

3

I’m assuming you are using an Unix system such as Linux or MacOS.

Maybe you are accidentally using the python2.7 version installed on your system.

You can use a specific version of python for pip with:

python3 -m pip install mysql-python

Let me explain myself, every MacOS or Linux system has two Python versions (2.7 and 3.x) by default, and both of those versions has a pip module related to it, in other words, you have a pip module for Python 2.7 and other pip module for Python 3.x.

However, I’m assuming you are using python3 for your project, therefore, you must specify the pip module to use.

Other way to avoid this problem is using a virtual environment manager, such as pipenv or built in virtualenv module.

Aldo RVV
  • 131
  • 2
  • 5
2

It looks like your pip package doesn't have the module "ConfigParser" installed. You should be able to install it by running:

pip install ConfigParser

Alternatively, depending on your Python version, try installing mysqlclient instead:

pip install mysqlclient
marc-92
  • 47
  • 3