Python3 and MySQL-python

I’m facing a terminal error on frappe init using python3 on mac that I can’t quite figure out. frappe_io seems to expect MySQL-python, but as I understand it that library isn’t available for python3. Any tips on how to proceed?

installing frappe_ioxxxxxx
INFO:bench.app:installing frappe_io
INFO:bench.utils:frappe-bench/env/bin/pip install -q  -e frappe-bench/apps/frappe_io --no-cache-dir
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/t9/7z0p020138s20gj3ymh069f00000gp/T/pip-install-m1ylw1dd/MySQL-python/
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 11, in <module>
    load_entry_point('bench', 'console_scripts', 'bench')()
  File "/Users/xxxxxx/bench-repo/bench/cli.py", line 40, in cli
    bench_command()
  File "/Users/xxxxxx/Library/Python/3.7/lib/python/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/Users/xxxxxx/Library/Python/3.7/lib/python/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/Users/xxxxxx/Library/Python/3.7/lib/python/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/xxxxxx/Library/Python/3.7/lib/python/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/xxxxxx/Library/Python/3.7/lib/python/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Users/xxxxxx/bench-repo/bench/commands/make.py", line 30, in init
    python 		 = python)
  File "/Users/xxxxxx/bench-repo/bench/utils.py", line 75, in init
    get_app(frappe_path, branch=frappe_branch, bench_path=path, build_asset_files=False, verbose=verbose)
  File "/Users/xxxxxx/bench-repo/bench/app.py", line 141, in get_app
    branch= 'master', postprocess = False)
  File "/Users/xxxxxx/bench-repo/bench/app.py", line 135, in get_app
    install_app(app=app_name, bench_path=bench_path, verbose=verbose)
  File "/Users/xxxxxx/bench-repo/bench/app.py", line 179, in install_app
    find_links=find_links))
  File "/Users/xxxxxx/bench-repo/bench/utils.py", line 159, in exec_cmd
    raise CommandFailedError(cmd)
bench.utils.CommandFailedError: frappe-bench/env/bin/pip install -q  -e frappe-bench/apps/frappe_io --no-cache-dir

Hello @peterg

Check your setup.py whether there is something wrong with the codebase.

1 Like

Thanks for responding!

Any tips on what I should be looking for? I re-obtained and re-installed the bench-repo thinking that might be the problem, but no luck

Here’s what my bench-repo/setup.py looks like:

computername:bench-repo username$ cat setup.py
from setuptools import setup, find_packages
import re, ast

# get version from __version__ variable in bench/__init__.py
_version_re = re.compile(r'__version__\s+=\s+(.*)')

with open('requirements.txt') as f:
	install_requires = f.read().strip().split('\n')

with open('bench/__init__.py', 'rb') as f:
	version = str(ast.literal_eval(_version_re.search(
		f.read().decode('utf-8')).group(1)))

setup(
	name='bench',
	description='Metadata driven, full-stack web framework',
	author='Frappe Technologies',
	author_email='info@frappe.io',
	version=version,
	packages=find_packages(),
	zip_safe=False,
	include_package_data=True,
	install_requires=install_requires,
	entry_points='''
[console_scripts]
bench=bench.cli:cli
''',
)

and here’s my version output

computername:bench-repo username$ bench --version
4.1.0

try this

1 Like

Thanks Prashant, that (plus a ton of manual installing in pip) got me a bit farther. Now, I’m facing an invalid syntax error:

17:46:45 watch.1          | yarn run v1.10.1
17:46:46 watch.1          | $ node rollup/watch.js
17:46:46 web.1            | Traceback (most recent call last):
17:46:46 web.1            |   File "/Users/xxxxxx/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 66, in get_app_commands
17:46:46 web.1            |     app_command_module = importlib.import_module(app + '.commands')
17:46:46 web.1            |   File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
17:46:46 web.1            |     return _bootstrap._gcd_import(name[level:], package, level)
17:46:46 web.1            |   File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
17:46:46 web.1            |   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
17:46:46 web.1            |   File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
17:46:46 web.1            |   File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
17:46:46 web.1            |   File "<frozen importlib._bootstrap_external>", line 728, in exec_module
17:46:46 web.1            |   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
17:46:46 web.1            |   File "/Users/xxxxxx/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 83, in <module>
17:46:46 web.1            |     commands = get_commands()
17:46:46 web.1            |   File "/Users/xxxxxx/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 77, in get_commands
17:46:46 web.1            |     from .site import commands as site_commands
17:46:46 web.1            |   File "/Users/xxxxxx/frappe-bench/apps/frappe/frappe/commands/site.py", line 8, in <module>
17:46:46 web.1            |     from frappe.limits import update_limits, get_limits
17:46:46 web.1            |   File "/Users/xxxxxx/frappe-bench/apps/frappe/frappe/limits.py", line 5, in <module>
17:46:46 web.1            |     from frappe.installer import update_site_config
17:46:46 web.1            |   File "/Users/xxxxxx/frappe-bench/apps/frappe/frappe/installer.py", line 20, in <module>
17:46:46 web.1            |     from frappe.website import render
17:46:46 web.1            |   File "/Users/xxxxxx/frappe-bench/apps/frappe/frappe/website/render.py", line 7, in <module>
17:46:46 web.1            |     import frappe.sessions
17:46:46 web.1            |   File "/Users/xxxxxx/frappe-bench/apps/frappe/frappe/sessions.py", line 18, in <module>
17:46:46 web.1            |     from frappe.utils.change_log import get_change_log
17:46:46 web.1            |   File "/Users/xxxxxx/frappe-bench/apps/frappe/frappe/utils/change_log.py", line 14, in <module>
17:46:46 web.1            |     import git
17:46:46 web.1            |   File "/usr/local/lib/python3.7/site-packages/git/__init__.py", line 33, in <module>
17:46:46 web.1            |     from git.config import GitConfigParser
17:46:46 web.1            |   File "/usr/local/lib/python3.7/site-packages/git/config.py", line 190
17:46:46 web.1            |     except IOError, e:
17:46:46 web.1            |                   ^
17:46:46 web.1            | SyntaxError: invalid syntax

I suspect this has something to do with my GitPython verison. Bench won’t run without version 0.3.2.1, but if that’s installed Frappe issues a warning that it needs version 2.1.11. Any sense of how I might proceed?

I managed to get the bench to start after manually editing some of the GitPython dependencies in requirements.txt, but when I tried to access the site the setup wizard was entirely borked. I suspect the installation really never completed properly.

I’m still stuck on the original error with frappe init. Bench seems to be trying to install MySQL-python in the process of setting up frappe_io, but that library doesn’t exist for python3. The only reference I can find to MySQL-python is in bench-repo/playbooks/macosx.yml, but even if I comment it out bench still tries to install it during the frappe_io setup process.

Not sure what else to do at this point.

The problem here, I’ve since discovered, is that frappe_io is trying to install a completely unrelated application for some reason.

Specifically, it’s trying to pull from GitHub - grafos-ml/frappe: Recommendations Serving Engine using python, which is a recommendation system backend with absolutely no relationship to the Frappe we know and love.

I don’t understand pip well enough to know why it’s looking for this grafos-ml package instead of the frappe I want, and I don’t have any idea how to fix it. I’ve been stuck on this for two weeks now, and it has completely stymied my dev system :frowning:

1 Like