最新消息:VPS服务器又从fzhost.net换回Linode了,主题仍用朋友推荐的大前端D8

【已解决】pyspider中运行result_worker出错:ModuleNotFoundError No module named mysql

pyspider crifan 311浏览 0评论

折腾:

【已解决】PySpider中保存数据到mysql

期间,pyspider中去运行result_worker但是出错:

<code>➜  AutocarData pyspider -c config.json result_worker
Traceback (most recent call last):
  File "/Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/bin/pyspider", line 11, in &lt;module&gt;
    sys.exit(main())
  File "/Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/site-packages/pyspider/run.py", line 754, in main
    cli()
  File "/Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/site-packages/pyspider/run.py", line 299, in result_worker
    result_worker = ResultWorker(resultdb=g.resultdb, inqueue=g.processor2result)
  File "/Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/site-packages/pyspider/libs/utils.py", line 355, in __getattr__
    return ret.__get__(self, ObjectDict)
  File "/Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/site-packages/pyspider/libs/utils.py", line 342, in __get__
    return self.getter()
  File "/Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/site-packages/pyspider/run.py", line 43, in &lt;lambda&gt;
    return utils.Get(lambda: connect_database(value))
  File "/Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/site-packages/pyspider/database/__init__.py", line 44, in connect_database
    db = _connect_database(url)
  File "/Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/site-packages/pyspider/database/__init__.py", line 64, in _connect_database
    return _connect_mysql(parsed,dbtype)
  File "/Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/site-packages/pyspider/database/__init__.py", line 116, in _connect_mysql
    from .mysql.resultdb import ResultDB
  File "/Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/site-packages/pyspider/database/mysql/resultdb.py", line 12, in &lt;module&gt;
    import mysql.connector
ModuleNotFoundError: No module named 'mysql'
</code>

感觉是:

pyspider中,mysql中的resultdb.py中找不到mysql

那去安装试试

pyspider mysql/resultdb.py

pyspider/resultdb.py at master · binux/pyspider

<code>import re

import six
import time
import json
import mysql.connector

from pyspider.libs import utils
from pyspider.database.base.resultdb import ResultDB as BaseResultDB
from pyspider.database.basedb import BaseDB
from .mysqlbase import MySQLMixin, SplitTableMixin
</code>

pyspider安装 – 孔扎根 – 博客园

请问,怎么自定义resultdb和resultworker,教程里面写的好模糊. – Google Groups

结果出错:

<code>➜  AutocarData pipenv install mysql
Installing mysql…
Looking in indexes: https://pypi.python.org/simple
Collecting mysql
  Downloading https://files.pythonhosted.org/packages/06/ef/c4efbf2a51fb46aba9be03a973638d9539c9ca10a5259b2cbb1a66133b2e/mysql-0.0.1.tar.gz
Collecting MySQL-python (from mysql)
  Downloading https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108kB)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "&lt;string&gt;", line 1, in &lt;module&gt;
      File "/private/var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/pip-install-ll0ndg5i/MySQL-python/setup.py", line 13, in &lt;module&gt;
        from setup_posix import get_config
      File "/private/var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/pip-install-ll0ndg5i/MySQL-python/setup_posix.py", line 2, in &lt;module&gt;
        from ConfigParser import SafeConfigParser
    ModuleNotFoundError: No module named 'ConfigParser'

    ----------------------------------------

Error:  An error occurred while installing mysql!
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/pip-install-ll0ndg5i/MySQL-python/
</code>

ModuleNotFoundError: No module named ‘ConfigParser’

Python 3 ImportError: No module named ‘ConfigParser’ – Stack Overflow

想要去看看出错的文件:

<code>➜  AutocarData cat /private/var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/pip-install-ll0ndg5i/MySQL-python/setup_posix.py
cat: /private/var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/pip-install-ll0ndg5i/MySQL-python/setup_posix.py: No such file or directory
</code>

结果找不到。

难看到是此处的MySQL-python,不支持python3?

ConfigParser 模块名字变化,引起 ImportError · Issue #12 · JinnLynn/genpac

mysql-python python3

python3.x如何安装MySQL-python(MySQLdb)? – 知乎

“MySQL-python不支持py3,可以pip install pymysql代替”

关于在Python3.5下安装MySQL-python模块的问题 – CSDN博客

参考:

https://blog.csdn.net/kk185800961/article/details/53296822

去复制,改名,试试

结果此处虚拟环境中Python

(从:

File “/Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/site-packages/pyspider/run.py”, line 754, in main

中可以看出路径是

/Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6)

中没有:

<code>➜  AutocarData ll /Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/
total 64
lrwxr-xr-x   1 crifan  staff   101B  4 21 14:37 __future__.py -&gt; /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/__future__.py
drwxr-xr-x  13 crifan  staff   416B  5  5 10:31 __pycache__
lrwxr-xr-x   1 crifan  staff   102B  4 21 14:37 _bootlocale.py -&gt; /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/_bootlocale.py
lrwxr-xr-x   1 crifan  staff   107B  4 21 14:37 _collections_abc.py -&gt; /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/_collections_abc.py
lrwxr-xr-x   1 crifan  staff   104B  4 21 14:37 _dummy_thread.py -&gt; /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/_dummy_thread.py
lrwxr-xr-x   1 crifan  staff   102B  4 21 14:37 _weakrefset.py -&gt; /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/_weakrefset.py
lrwxr-xr-x   1 crifan  staff    94B  4 21 14:37 abc.py -&gt; /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/abc.py
lrwxr-xr-x   1 crifan  staff    97B  4 21 14:37 base64.py -&gt; /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/base64.py
lrwxr-xr-x   1 crifan  staff    97B  4 21 14:37 bisect.py -&gt; /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/bisect.py
lrwxr-xr-x   1 crifan  staff    97B  4 21 14:37 codecs.py -&gt; /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/codecs.py
lrwxr-xr-x   1 crifan  staff    99B  4 21 14:37 collections -&gt; /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/collections
lrwxr-xr-x   1 crifan  staff   106B  4 21 14:37 config-3.6m-darwin -&gt; /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin
lrwxr-xr-x   1 crifan  staff    95B  4 21 14:37 copy.py -&gt; /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/copy.py
lrwxr-xr-x   1 crifan  staff    98B  4 21 14:37 copyreg.py -&gt; /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/copyreg.py
drwxr-xr-x   4 crifan  staff   128B  4 21 14:37 distutils
...
</code>

然后发现软连接指向的:

/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6

中有configparser.py:

<code>➜  AutocarData ll /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6
total 8928
-rw-r--r--    1 crifan  admin    12K 12 19 13:36 LICENSE.txt
-rw-r--r--    1 crifan  admin   4.7K 12 19 13:36 __future__.py
-rw-r--r--    1 crifan  admin    64B 12 19 13:36 __phello__.foo.py
drwxr-xr-x  108 crifan  admin   3.4K  4 17 12:01 __pycache__
-rw-r--r--    1 crifan  admin   1.3K 12 19 13:36 _bootlocale.py
-rw-r--r--    1 crifan  admin    26K 12 19 13:36 _collections_abc.py
-rw-r--r--    1 crifan  admin   8.5K 12 19 13:36 _compat_pickle.py
-rw-r--r--    1 crifan  admin   5.2K 12 19 13:36 _compression.py
-rw-r--r--    1 crifan  admin   5.0K 12 19 13:36 _dummy_thread.py
-rw-r--r--    1 crifan  admin    14K 12 19 13:36 _markupbase.py
-rw-r--r--    1 crifan  admin    19K 12 19 13:36 _osx_support.py
-rw-r--r--    1 crifan  admin   225K 12 19 13:36 _pydecimal.py
-rw-r--r--    1 crifan  admin    86K 12 19 13:36 _pyio.py
-rw-r--r--    1 crifan  admin   3.0K 12 19 13:36 _sitebuiltins.py
-rw-r--r--    1 crifan  admin    24K 12 19 13:36 _strptime.py
-rw-r--r--    1 crifan  admin    21K  4 17 10:52 _sysconfigdata_m_darwin_darwin.py
-rw-r--r--    1 crifan  admin   7.2K 12 19 13:36 _threading_local.py
-rw-r--r--    1 crifan  admin   5.6K 12 19 13:36 _weakrefset.py
-rw-r--r--    1 crifan  admin   8.4K 12 19 13:36 abc.py
-rw-r--r--    1 crifan  admin    32K 12 19 13:36 aifc.py
-rw-r--r--    1 crifan  admin   476B 12 19 13:36 antigravity.py
-rw-r--r--    1 crifan  admin    88K 12 19 13:36 argparse.py
-rw-r--r--    1 crifan  admin    12K 12 19 13:36 ast.py
-rw-r--r--    1 crifan  admin    11K 12 19 13:36 asynchat.py
drwxr-xr-x   28 crifan  admin   896B  4 20 16:55 asyncio
-rw-r--r--    1 crifan  admin    20K 12 19 13:36 asyncore.py
-rwxr-xr-x    1 crifan  admin    20K 12 19 13:36 base64.py
-rw-r--r--    1 crifan  admin    23K 12 19 13:36 bdb.py
-rw-r--r--    1 crifan  admin    14K 12 19 13:36 binhex.py
-rw-r--r--    1 crifan  admin   2.5K 12 19 13:36 bisect.py
-rw-r--r--    1 crifan  admin    12K 12 19 13:36 bz2.py
-rwxr-xr-x    1 crifan  admin   5.2K 12 19 13:36 cProfile.py
-rw-r--r--    1 crifan  admin    23K 12 19 13:36 calendar.py
-rwxr-xr-x    1 crifan  admin    35K  4 17 10:52 cgi.py
-rw-r--r--    1 crifan  admin    12K 12 19 13:36 cgitb.py
-rw-r--r--    1 crifan  admin   5.3K 12 19 13:36 chunk.py
-rw-r--r--    1 crifan  admin    15K 12 19 13:36 cmd.py
-rw-r--r--    1 crifan  admin    10K 12 19 13:36 code.py
-rw-r--r--    1 crifan  admin    35K 12 19 13:36 codecs.py
-rw-r--r--    1 crifan  admin   5.9K 12 19 13:36 codeop.py
drwxr-xr-x    5 crifan  admin   160B  4 17 10:52 collections
-rw-r--r--    1 crifan  admin   4.0K 12 19 13:36 colorsys.py
-rw-r--r--    1 crifan  admin    12K 12 19 13:36 compileall.py
drwxr-xr-x    5 crifan  admin   160B  4 17 11:05 concurrent
drwxr-xr-x   16 crifan  admin   512B  4 17 10:52 config-3.6m-darwin
-rw-r--r--    1 crifan  admin    52K 12 19 13:36 configparser.py
-rw-r--r--    1 crifan  admin    13K 12 19 13:36 contextlib.py
-rw-r--r--    1 crifan  admin   8.6K 12 19 13:36 copy.py
-rw-r--r--    1 crifan  admin   6.8K 12 19 13:36 copyreg.py
-rw-r--r--    1 crifan  admin   1.8K 12 19 13:36 crypt.py
-rw-r--r--    1 crifan  admin    16K 12 19 13:36 csv.py
drwxr-xr-x    9 crifan  admin   288B  4 17 10:52 ctypes
drwxr-xr-x    7 crifan  admin   224B 12 19 13:36 curses
-rw-r--r--    1 crifan  admin    78K 12 19 13:36 datetime.py
。。。
</code>

所以去拷贝:

<code>➜  AutocarData cp /usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/configparser.py /Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/ConfigParser.py
➜  AutocarData ll /Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/C*
-rw-r--r--  1 crifan  staff    52K  5  5 22:31 /Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/ConfigParser.py
➜  AutocarData
</code>

然后再继续去安装

真的可以安装了:

<code>➜  AutocarData pipenv install mysql
Installing mysql…
Looking in indexes: https://pypi.python.org/simple
Collecting mysql
  Using cached https://files.pythonhosted.org/packages/06/ef/c4efbf2a51fb46aba9be03a973638d9539c9ca10a5259b2cbb1a66133b2e/mysql-0.0.1.tar.gz
Collecting MySQL-python (from mysql)
  Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
Building wheels for collected packages: mysql, MySQL-python
  Running setup.py bdist_wheel for mysql: started
  Running setup.py bdist_wheel for mysql: finished with status 'done'
  Stored in directory: /Users/crifan/Library/Caches/pip/wheels/96/73/eb/6d88266f5f622b9a091c0ef5eb5a3fedb4d4e36de3f635e337
  Running setup.py bdist_wheel for MySQL-python: started
  Running setup.py bdist_wheel for MySQL-python: finished with status 'done'
  Stored in directory: /Users/crifan/Library/Caches/pip/wheels/07/d2/5f/314860e4cb53a44bf0ee0d051d4b34465e4b4fbe9de6d42f42
Successfully built mysql MySQL-python
Installing collected packages: MySQL-python, mysql
Successfully installed MySQL-python-1.2.5 mysql-0.0.1

Adding mysql to Pipfile's [packages]…
Pipfile.lock (b95d9c) out of date, updating to (51fb1f)…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (51fb1f)!
Installing dependencies from Pipfile.lock (51fb1f)…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 3/3 — 00:00:00
➜  AutocarData
</code>

不知道后续是否能正常使用。

毕竟别人好像说是:

MySQL-python不支持Python3?

而我此处是虚拟环境中的Python3.6

<code>➜  AutocarData which python
/Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/bin/python
➜  AutocarData python --version
Python 3.6.4
</code>

然后继续运行试试:

结果错误依旧

但是去看看,是已经安装的:

<code>➜  AutocarData pipenv graph
mysql==0.0.1
  - MySQL-python [required: Any, installed: 1.2.5]
PyMySQL==0.8.0
pyspider==0.3.10
  - chardet [required: &gt;=2.2, installed: 3.0.4]
  - click [required: &gt;=3.3, installed: 6.7]
  - cssselect [required: &gt;=0.9, installed: 1.0.3]
  - Flask [required: &gt;=0.10, installed: 0.12.2]
    - click [required: &gt;=2.0, installed: 6.7]
    - itsdangerous [required: &gt;=0.21, installed: 0.24]
    - Jinja2 [required: &gt;=2.4, installed: 2.10]
      - MarkupSafe [required: &gt;=0.23, installed: 1.0]
    - Werkzeug [required: &gt;=0.7, installed: 0.14.1]
  - Flask-Login [required: &gt;=0.2.11, installed: 0.4.1]
    - Flask [required: Any, installed: 0.12.2]
      - click [required: &gt;=2.0, installed: 6.7]
      - itsdangerous [required: &gt;=0.21, installed: 0.24]
      - Jinja2 [required: &gt;=2.4, installed: 2.10]
        - MarkupSafe [required: &gt;=0.23, installed: 1.0]
      - Werkzeug [required: &gt;=0.7, installed: 0.14.1]
  - Jinja2 [required: &gt;=2.7, installed: 2.10]
    - MarkupSafe [required: &gt;=0.23, installed: 1.0]
  - lxml [required: Any, installed: 4.2.1]
  - pycurl [required: Any, installed: 7.43.0.1]
  - pyquery [required: Any, installed: 1.4.0]
    - cssselect [required: &gt;0.7.9, installed: 1.0.3]
    - lxml [required: &gt;=2.1, installed: 4.2.1]
  - requests [required: &gt;=2.2, installed: 2.18.4]
    - certifi [required: &gt;=2017.4.17, installed: 2018.4.16]
    - chardet [required: &lt;3.1.0,&gt;=3.0.2, installed: 3.0.4]
    - idna [required: &lt;2.7,&gt;=2.5, installed: 2.6]
    - urllib3 [required: &gt;=1.21.1,&lt;1.23, installed: 1.22]
  - six [required: &gt;=1.5.0, installed: 1.11.0]
  - tblib [required: &gt;=1.3.0, installed: 1.3.2]
  - tornado [required: &gt;=3.2,&lt;=4.5.3, installed: 4.5.3]
  - u-msgpack-python [required: &gt;=1.6, installed: 2.5.0]
  - wsgidav [required: &gt;=2.0.0, installed: 2.3.0]
    - defusedxml [required: Any, installed: 0.5.0]
</code>

然后python命令行试试,也是同样错误:

<code>➜  AutocarData python
Python 3.6.4 (default, Mar 22 2018, 13:54:22)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
&gt;&gt;&gt; import mysql
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
ModuleNotFoundError: No module named 'mysql'
&gt;&gt;&gt;
</code>

ModuleNotFoundError: No module named ‘mysql’

突然想到,难道是:

安装之前在:

【已解决】Python3中选择合适的mysql的连接器或驱动

提到的:

mysqlclient

或许是安装了后,就可以直接

import mysql

了?

去试试:

<code>➜  AutocarData pipenv install mysqlclient
Installing mysqlclient…
Looking in indexes: https://pypi.python.org/simple
Collecting mysqlclient
  Downloading https://files.pythonhosted.org/packages/6f/86/bad31f1c1bb0cc99e88ca2adb7cb5c71f7a6540c1bb001480513de76a931/mysqlclient-1.3.12.tar.gz (89kB)
Building wheels for collected packages: mysqlclient
  Running setup.py bdist_wheel for mysqlclient: started
  Running setup.py bdist_wheel for mysqlclient: finished with status 'done'
  Stored in directory: /Users/crifan/Library/Caches/pip/wheels/50/c7/31/81a516762c8e9324f2b1fdffc1e84b9f07224fe3707956f6e1
Successfully built mysqlclient
Installing collected packages: mysqlclient
Successfully installed mysqlclient-1.3.12

Adding mysqlclient to Pipfile's [packages]…
Pipfile.lock (51fb1f) out of date, updating to (4388e5)…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
^C
Aborted!
➜  AutocarData
➜  AutocarData
➜  AutocarData pipenv install mysqlclient
Installing mysqlclient…
Looking in indexes: https://pypi.python.org/simple
Requirement already satisfied: mysqlclient in /Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/site-packages (1.3.12)

Adding mysqlclient to Pipfile's [packages]…
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
</code>

结果死掉了的感觉。。。

过了好半天才可以

<code>Updated Pipfile.lock (4388e5)!
Installing dependencies from Pipfile.lock (4388e5)…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 4/4 — 00:00
</code>

然后再去shell中试试import mysql是否可以导入

错误依旧。

<code>➜  AutocarData pipenv install mysql-connector-python
Installing mysql-connector-python…
Looking in indexes: https://pypi.python.org/simple
Collecting mysql-connector-python
  Downloading https://files.pythonhosted.org/packages/89/a5/306406aa0a1a36b3bb19d569d98c3918473af59de56c6eca67b780382f41/mysql_connector_python-8.0.11-cp36-cp36m-macosx_10_12_x86_64.whl (3.3MB)
Collecting protobuf&gt;=3.0.0 (from mysql-connector-python)
  Downloading https://files.pythonhosted.org/packages/eb/a7/042722bc48082f6b02498ebdf4e64a6d1b4543271d4f2f495641f429c56d/protobuf-3.5.2.post1-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (1.2MB)
Requirement already satisfied: six&gt;=1.9 in /Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/site-packages (from protobuf&gt;=3.0.0-&gt;mysql-connector-python) (1.11.0)
Requirement already satisfied: setuptools in /Users/crifan/.local/share/virtualenvs/AutocarData-xI-iqIq4/lib/python3.6/site-packages (from protobuf&gt;=3.0.0-&gt;mysql-connector-python) (39.0.1)
Installing collected packages: protobuf, mysql-connector-python
Successfully installed mysql-connector-python-8.0.11 protobuf-3.5.2.post1

Adding mysql-connector-python to Pipfile's [packages]…
Pipfile.lock (4388e5) out of date, updating to (4dbe95)…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
Updated Pipfile.lock (4dbe95)!
Installing dependencies from Pipfile.lock (4dbe95)…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 7/7 —
</code>

【总结】

此处:

<code>pyspider -c config.json result_worker
</code>

结果说是找不到mysql

折腾了半天,貌似此处是安装了:

<code>pipenv install mysql-connector-python
</code>

好像解决了这个问题。

从而使得pyspider中的

import mysql

可以正常运行了,所以好像消除了错误了。

转载请注明:在路上 » 【已解决】pyspider中运行result_worker出错:ModuleNotFoundError No module named mysql

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
17 queries in 0.303 seconds, using 10.74MB memory