最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

【已解决】PyCharm中调试出错:ModuleNotFoundError: No module named

PyCharm crifan 2410浏览 0评论

折腾:

【已解决】合并基于搜索的兜底对话到产品Demo中

期间,想要去调试,结果:

<code>ModuleNotFoundError: No module named 'numpy'
</code>

所以去安装库:

<code>➜  xx git:(master) ✗ which python
/Users/crifan/.local/share/virtualenvs/xx-gXiJ4vtz/bin/python
➜  xx git:(master) ✗ pipenv install numpy
Installing numpy...
⠙
</code>

结果又是遇到之前的pipenv的bug:lock卡死

参考之前的:

【已解决】pipenv install PySpider卡死在:Locking [packages] dependencies

去改为:

<code>[[source]]
# url = "https://pypi.python.org/simple"
url = "https://pypi.tuna.tsinghua.edu.cn/simple"
verify_ssl = true
name = "pypi"

[packages]
pymysql = "*"
openpyxl = "*"
pymongo = "*"
torndb = "*"

[dev-packages]

[requires]
python_version = "3.6"
</code>

结果:

<code>➜  x git:(master) ✗ pipenv install numpy
Installing numpy...
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting numpy
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/6a/d5/218414f0f41cb3f183d55d68dbcd996fa3602d5849bdf2ad6c059e98fa68/numpy-1.15.0-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 (24.5MB)
Installing collected packages: numpy
Successfully installed numpy-1.15.0

Adding numpy to Pipfile's [packages]...
Pipfile.lock (a5428b) out of date, updating to (1d10a5)...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...


</code>

好像也卡死了:

不过可以看到已经是安装好了numpy了:

继续遇到类似问题:

ModuleNotFoundError: No module named ‘requests’

所以去继续安装

pipenv install requests

还是lock卡死

参考:

Pipenv lock fails to resolve dependencies · Issue #1579 · pypa/pipenv

去试试:

–skip-lock

不过刚发现,lock成功了,只不过很慢,花了好半天才结束而已:

<code>➜  x git:(master) ✗ pipenv install requests
Installing requests...
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting requests
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/65/47/7e02164a2a3db50ed6d8a6ab1d6d60b69c4c3fdf57a284257925dfc12bda/requests-2.19.1-py2.py3-none-any.whl
Collecting certifi&gt;=2017.4.17 (from requests)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/16/1f/50d729c104b21c1042aa51560da6141d1cab476ba7015d92b2111c8db841/certifi-2018.8.13-py2.py3-none-any.whl (146kB)
Collecting idna&lt;2.8,&gt;=2.5 (from requests)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl
Collecting chardet&lt;3.1.0,&gt;=3.0.2 (from requests)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Collecting urllib3&lt;1.24,&gt;=1.21.1 (from requests)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/bd/c9/6fdd990019071a4a32a5e7cb78a1d92c53851ef4f56f62a3486e6a7d8ffb/urllib3-1.23-py2.py3-none-any.whl
Installing collected packages: certifi, idna, chardet, urllib3, requests
Successfully installed certifi-2018.8.13 chardet-3.0.4 idna-2.7 requests-2.19.1 urllib3-1.23

Adding requests to Pipfile's [packages]...
Pipfile.lock (a5428b) out of date, updating to (79b8e4)...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Updated Pipfile.lock (79b8e4)!
Installing dependencies from Pipfile.lock (79b8e4)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 17/17 — 00:00:11
</code>

继续安装其他的库

<code>    import schedule, time
ModuleNotFoundError: No module named 'schedule'
</code>

安装:

<code>➜  x git:(master) ✗ pipenv install schedule
Installing schedule...
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting schedule
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/df/2c/3a94d846682a4fb94966e65bca19a1acb6f7dd85977f4e4cece6e677b757/schedule-0.5.0-py2.py3-none-any.whl
Installing collected packages: schedule
Successfully installed schedule-0.5.0

Adding schedule to Pipfile's [packages]...
Pipfile.lock (79b8e4) out of date, updating to (dcd3f4)...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Updated Pipfile.lock (dcd3f4)!
Installing dependencies from Pipfile.lock (dcd3f4)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 18/18 — 00:00:04
</code>

以及:

<code>    import pylru
ModuleNotFoundError: No module named 'pylru'
</code>

安装:

<code>➜  x git:(master) ✗ pipenv install pylru
Installing pylru...
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pylru
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/2e/6f/7533e986bed3ec224f02d913f34ab6e110fb0286795c1f6e18e66e03a9f0/pylru-1.1.0.tar.gz
Building wheels for collected packages: pylru
  Running setup.py bdist_wheel for pylru: started
  Running setup.py bdist_wheel for pylru: finished with status 'done'
  Stored in directory: /Users/crifan/Library/Caches/pipenv/wheels/74/7a/79/aeaa108d68d8684980c129747875ab3bd541dbb2a9d2bc6c88
Successfully built pylru
Installing collected packages: pylru
Successfully installed pylru-1.1.0

Adding pylru to Pipfile's [packages]...
Pipfile.lock (dcd3f4) out of date, updating to (fa322a)...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Updated Pipfile.lock (fa322a)!
Installing dependencies from Pipfile.lock (fa322a)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 19/19 — 00:00:04
</code>

另外,再去参考:

Frequently Encountered Pipenv Problems — pipenv 2018.7.1.dev0 documentation

去试试:

pipenvlock –clear

问题依旧,还是卡死:

<code>➜  x git:(master) ✗ pipenv lock --clear
Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead.
Locking [dev-packages] dependencies...
Locking [packages] dependencies...


</code>

算了,不管pipenv的bug了。

还是切换回tinhua的源吧。

ModuleNotFoundError: No module named ‘jieba’

安装:

<code>➜  x git:(master) ✗ pipenv install jieba
Installing jieba...
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting jieba
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/71/46/c6f9179f73b818d5827202ad1c4a94e371a29473b7f043b736b4dab6b8cd/jieba-0.39.zip (7.3MB)
Building wheels for collected packages: jieba
  Running setup.py bdist_wheel for jieba: started
  Running setup.py bdist_wheel for jieba: finished with status 'done'
  Stored in directory: /Users/crifan/Library/Caches/pipenv/wheels/9d/32/c2/1cc7447fe6f7b573da7e4f02909de0accad87667eb80d3ecdb
Successfully built jieba
Installing collected packages: jieba
Successfully installed jieba-0.39

Adding jieba to Pipfile's [packages]...
Pipfile.lock (fa322a) out of date, updating to (1904e0)...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Updated Pipfile.lock (1904e0)!
Installing dependencies from Pipfile.lock (1904e0)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 20/20 — 00:00:04
</code>

再去:

ModuleNotFoundError: No module named ‘pycnnum’

安装:

<code>➜  x git:(master) ✗ pipenv install pycnnum
Installing pycnnum...
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pycnnum
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/dd/42/ca3efad36831c0123ea6fa147020f50e3f478ed26fcfcce6101e201f11fb/pycnnum-1.0.1-py3-none-any.whl
Installing collected packages: pycnnum
Successfully installed pycnnum-1.0.1

Adding pycnnum to Pipfile's [packages]...
Pipfile.lock (1904e0) out of date, updating to (a35be3)...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Updated Pipfile.lock (a35be3)!
Installing dependencies from Pipfile.lock (a35be3)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 21/21 — 00:00:04
</code>

以及:

<code>  File "/Users/crifan/dev/dev_root/xx/search/utils/solr_util.py", line 21, in &lt;module&gt;
    from SolrClient import SolrClient
ModuleNotFoundError: No module named 'SolrClient'
</code>

安装:

<code>➜  x git:(master) ✗ pipenv install SolrClient
Installing SolrClient...
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting SolrClient
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/8b/f1/9016a502695fd8de660ab15db30dae38bcc0c038381690f966571ddaa116/SolrClient-0.2.1.tar.gz
Requirement already satisfied: requests&gt;=2.2.1 in /Users/crifan/.local/share/virtualenvs/x-gXiJ4vtz/lib/python3.6/site-packages (from SolrClient) (2.19.1)
Collecting kazoo==2.2.1 (from SolrClient)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/66/55/d9c8b55a4037bb21acc92c74c9854bf5a9eeaa3798fc3a665060d463827e/kazoo-2.2.1-py2.py3-none-any.whl (121kB)
Requirement already satisfied: certifi&gt;=2017.4.17 in /Users/crifan/.local/share/virtualenvs/x-gXiJ4vtz/lib/python3.6/site-packages (from requests&gt;=2.2.1-&gt;SolrClient) (2018.4.16)
Requirement already satisfied: urllib3&lt;1.24,&gt;=1.21.1 in /Users/crifan/.local/share/virtualenvs/x-gXiJ4vtz/lib/python3.6/site-packages (from requests&gt;=2.2.1-&gt;SolrClient) (1.23)
Requirement already satisfied: idna&lt;2.8,&gt;=2.5 in /Users/crifan/.local/share/virtualenvs/x-gXiJ4vtz/lib/python3.6/site-packages (from requests&gt;=2.2.1-&gt;SolrClient) (2.7)
Requirement already satisfied: chardet&lt;3.1.0,&gt;=3.0.2 in /Users/crifan/.local/share/virtualenvs/x-gXiJ4vtz/lib/python3.6/site-packages (from requests&gt;=2.2.1-&gt;SolrClient) (3.0.4)
Requirement already satisfied: six in /Users/crifan/.local/share/virtualenvs/x-gXiJ4vtz/lib/python3.6/site-packages (from kazoo==2.2.1-&gt;SolrClient) (1.11.0)
Building wheels for collected packages: SolrClient
  Running setup.py bdist_wheel for SolrClient: started
  Running setup.py bdist_wheel for SolrClient: finished with status 'done'
  Stored in directory: /Users/crifan/Library/Caches/pipenv/wheels/8d/37/15/58ab6b103a289e0a5fddfa9be5192403388d849bc44c68d96f
Successfully built SolrClient
Installing collected packages: kazoo, SolrClient
Successfully installed SolrClient-0.2.1 kazoo-2.2.1

Adding SolrClient to Pipfile's [packages]...
Pipfile.lock (a35be3) out of date, updating to (fe41a4)...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Updated Pipfile.lock (fe41a4)!
Installing dependencies from Pipfile.lock (fe41a4)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 23/23 — 00:00:04
</code>

ModuleNotFoundError: No module named ‘gensim’

安装:

<code>➜  x git:(master) ✗ pipenv install gensim    
Installing gensim...
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting gensim
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/cb/d9/f5adaf1108aad2b3d32a11aceede54faa5da9dbf962e9bcff759e1d27bd3/gensim-3.5.0-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 (23.7MB)
Collecting scipy&gt;=0.18.1 (from gensim)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a0/b6/70bf61c1badb5fea82d4c558e05e76c2dee5e77bb072fe465d7c7a87287d/scipy-1.1.0-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 (16.7MB)
Requirement already satisfied: numpy&gt;=1.11.3 in /Users/crifan/.local/share/virtualenvs/x-gXiJ4vtz/lib/python3.6/site-packages (from gensim) (1.15.0)
Collecting smart-open&gt;=1.2.1 (from gensim)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/cf/3d/5f3a9a296d0ba8e00e263a8dee76762076b9eb5ddc254ccaa834651c8d65/smart_open-1.6.0.tar.gz
Requirement already satisfied: six&gt;=1.5.0 in /Users/crifan/.local/share/virtualenvs/x-gXiJ4vtz/lib/python3.6/site-packages (from gensim) (1.11.0)
Collecting boto&gt;=2.32 (from smart-open&gt;=1.2.1-&gt;gensim)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/23/10/c0b78c27298029e4454a472a1919bde20cb182dab1662cec7f2ca1dcc523/boto-2.49.0-py2.py3-none-any.whl (1.4MB)
Collecting bz2file (from smart-open&gt;=1.2.1-&gt;gensim)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/61/39/122222b5e85cd41c391b68a99ee296584b2a2d1d233e7ee32b4532384f2d/bz2file-0.98.tar.gz
Requirement already satisfied: requests in /Users/crifan/.local/share/virtualenvs/x-gXiJ4vtz/lib/python3.6/site-packages (from smart-open&gt;=1.2.1-&gt;gensim) (2.19.1)
Collecting boto3 (from smart-open&gt;=1.2.1-&gt;gensim)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1d/c4/e6af1f1edb6a89c94fd92e33dd82efecb2706a15e255cf0639820adb509d/boto3-1.7.77-py2.py3-none-any.whl (128kB)
Requirement already satisfied: urllib3&lt;1.24,&gt;=1.21.1 in /Users/crifan/.local/share/virtualenvs/x-gXiJ4vtz/lib/python3.6/site-packages (from requests-&gt;smart-open&gt;=1.2.1-&gt;gensim) (1.23)
Requirement already satisfied: chardet&lt;3.1.0,&gt;=3.0.2 in /Users/crifan/.local/share/virtualenvs/x-gXiJ4vtz/lib/python3.6/site-packages (from requests-&gt;smart-open&gt;=1.2.1-&gt;gensim) (3.0.4)
Requirement already satisfied: certifi&gt;=2017.4.17 in /Users/crifan/.local/share/virtualenvs/x-gXiJ4vtz/lib/python3.6/site-packages (from requests-&gt;smart-open&gt;=1.2.1-&gt;gensim) (2018.4.16)
Requirement already satisfied: idna&lt;2.8,&gt;=2.5 in /Users/crifan/.local/share/virtualenvs/x-gXiJ4vtz/lib/python3.6/site-packages (from requests-&gt;smart-open&gt;=1.2.1-&gt;gensim) (2.7)
Collecting jmespath&lt;1.0.0,&gt;=0.7.1 (from boto3-&gt;smart-open&gt;=1.2.1-&gt;gensim)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b7/31/05c8d001f7f87f0f07289a5fc0fc3832e9a57f2dbd4d3b0fee70e0d51365/jmespath-0.9.3-py2.py3-none-any.whl
Collecting botocore&lt;1.11.0,&gt;=1.10.77 (from boto3-&gt;smart-open&gt;=1.2.1-&gt;gensim)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/02/d3/14767ed0b8324e611b9b79fa23171164671e5ab8f4b1006bd00b1419b0f3/botocore-1.10.77-py2.py3-none-any.whl (4.5MB)
Collecting s3transfer&lt;0.2.0,&gt;=0.1.10 (from boto3-&gt;smart-open&gt;=1.2.1-&gt;gensim)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d7/14/2a0004d487464d120c9fb85313a75cd3d71a7506955be458eebfe19a6b1d/s3transfer-0.1.13-py2.py3-none-any.whl (59kB)
Collecting python-dateutil&lt;3.0.0,&gt;=2.1; python_version &gt;= "2.7" (from botocore&lt;1.11.0,&gt;=1.10.77-&gt;boto3-&gt;smart-open&gt;=1.2.1-&gt;gensim)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/cf/f5/af2b09c957ace60dcfac112b669c45c8c97e32f94aa8b56da4c6d1682825/python_dateutil-2.7.3-py2.py3-none-any.whl (211kB)
Collecting docutils&gt;=0.10 (from botocore&lt;1.11.0,&gt;=1.10.77-&gt;boto3-&gt;smart-open&gt;=1.2.1-&gt;gensim)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/36/fa/08e9e6e0e3cbd1d362c3bbee8d01d0aedb2155c4ac112b19ef3cae8eed8d/docutils-0.14-py3-none-any.whl (543kB)
Building wheels for collected packages: smart-open, bz2file
  Running setup.py bdist_wheel for smart-open: started
  Running setup.py bdist_wheel for smart-open: finished with status 'done'
  Stored in directory: /Users/crifan/Library/Caches/pipenv/wheels/6f/9b/b0/0f91e3feae863f5f98074225b5f8b13dda04687901209fca9d
  Running setup.py bdist_wheel for bz2file: started
  Running setup.py bdist_wheel for bz2file: finished with status 'done'
  Stored in directory: /Users/crifan/Library/Caches/pipenv/wheels/54/d5/83/67f5555780de56231a2e7cebe2632a1acb14d93c645f2e0ca8
Successfully built smart-open bz2file
Installing collected packages: scipy, boto, bz2file, jmespath, python-dateutil, docutils, botocore, s3transfer, boto3, smart-open, gensim
Successfully installed boto-2.49.0 boto3-1.7.77 botocore-1.10.77 bz2file-0.98 docutils-0.14 gensim-3.5.0 jmespath-0.9.3 python-dateutil-2.7.3 s3transfer-0.1.13 scipy-1.1.0 smart-open-1.6.0

Adding gensim to Pipfile's [packages]...
Pipfile.lock (fe41a4) out of date, updating to (6bc54a)...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Updated Pipfile.lock (6bc54a)!
Installing dependencies from Pipfile.lock (6bc54a)...
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 34/34 — 00:00:10
</code>

然后即可去运行了。

至少是缺少的库都安装好了。

转载请注明:在路上 » 【已解决】PyCharm中调试出错:ModuleNotFoundError: No module named

发表我的评论
取消评论

表情

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

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
61 queries in 0.124 seconds, using 18.89MB memory