python - 尝试导入“ruamel.yaml”库会导致“ImportError: No module named ruamel.yaml”错误
问题描述
我跑了一个
pip install ruamel.yaml
当我尝试做
import ruamel.yaml
我收到一个错误:
ImportError: No module named ruamel.yaml
蟒蛇2.7,
我的点子“冻结”的输出:
nose==1.3.7
numpy==1.12.1
pandas==0.23.3
python-dateutil==2.7.3
pytz==2018.5
PyYAML==3.13
ruamel.ordereddict==0.4.13
ruamel.yaml==0.15.46
six==1.11.0
解决方案
Linux(解决方案):
$ uname
Linux
$ virtualenv -p /opt/python/2.7/bin/python /var/tmp/so_51581941
Running virtualenv with interpreter /opt/python/2.7/bin/python
New python executable in /var/tmp/so_51581941/bin/python
Installing setuptools, pip, wheel...done.
$ source /var/tmp/so_51581941/bin/activate
(so_51581941) $ pip install ruamel.yaml
Collecting ruamel.yaml
Downloading https://files.pythonhosted.org/packages/b1/30/3d5c9bc3955136027177a7bbe4cf9ec94504d8cba851ce391eb2e9633db5/ruamel.yaml-0.15.46-cp27-cp27mu-manylinux1_x86_64.whl (592kB)
100% |████████████████████████████████| 593kB 2.9MB/s
Collecting ruamel.ordereddict; platform_python_implementation == "CPython" and python_version <= "2.7" (from ruamel.yaml)
Downloading https://files.pythonhosted.org/packages/f3/2c/fa6d75dc459b371ed3b88fdbf8042785ce1655073c884fd97bdbb9f48e01/ruamel.ordereddict-0.4.13-cp27-cp27mu-manylinux1_x86_64.whl (99kB)
100% |████████████████████████████████| 102kB 3.8MB/s
Installing collected packages: ruamel.ordereddict, ruamel.yaml
Successfully installed ruamel.ordereddict-0.4.13 ruamel.yaml-0.15.46
(so_51581941) $ pip freeze
ruamel.ordereddict==0.4.13
ruamel.yaml==0.15.46
(so_51581941) $ python -c "import ruamel.yaml"
(so_51581941) $ deactivate
$
苹果系统:
$ uname
Darwin
$ which python2.7
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
$ virtualenv -p /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /var/tmp/so_51581941
Running virtualenv with interpreter /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
New python executable in /var/tmp/so_51581941/bin/python
Installing setuptools, pip, wheel...done.
$ source /var/tmp/so_51581941/bin/activate
(so_51581941) $ pip install ruamel.yaml
Collecting ruamel.yaml
Downloading https://files.pythonhosted.org/packages/cd/0e/0e21d703e775f94447d6889ec231309679cb684347868b4b1e73e08510fd/ruamel.yaml-0.15.46-cp27-cp27m-macosx_10_9_x86_64.whl (236kB)
100% |████████████████████████████████| 245kB 3.5MB/s
Collecting ruamel.ordereddict; platform_python_implementation == "CPython" and python_version <= "2.7" (from ruamel.yaml)
Downloading https://files.pythonhosted.org/packages/b1/8f/3b1b407ff387e006a4a33e62182b212077bed41676451d60327955a50c3c/ruamel.ordereddict-0.4.13.tar.gz (57kB)
100% |████████████████████████████████| 61kB 3.6MB/s
Building wheels for collected packages: ruamel.ordereddict
Running setup.py bdist_wheel for ruamel.ordereddict ... done
Stored in directory: /Users/builder/Library/Caches/pip/wheels/5e/76/38/d2f83b281e02aa1bac95b2663ea19ed022440033b61e47ac3a
Successfully built ruamel.ordereddict
Installing collected packages: ruamel.ordereddict, ruamel.yaml
Successfully installed ruamel.ordereddict-0.4.13 ruamel.yaml-0.15.46
(so_51581941) $ pip freeze
ruamel.ordereddict==0.4.13
ruamel.yaml==0.15.46
(so_51581941) $ python -c "import ruamel.yaml"
(so_51581941) $ deactivate
$
视窗:
$ python -c "import sys; print(sys.platform)"
win32
$ virtualenv -p c:\Python\2.7\python.exe %TMP%\so_51581941
Running virtualenv with interpreter c:\Python\2.7\python.exe
New python executable in C:\Users\Anthon\AppData\Local\Temp\so_51581941\Scripts\
python.exe
Installing setuptools, pip, wheel...done.
$ %TMP%\so_51581941\Scripts\activate
(so_51581941) $ pip install ruamel.yaml
Collecting ruamel.yaml
Downloading https://files.pythonhosted.org/packages/70/79/337d043310c8b9fe7978a9ab72b7838b8088785a66a69cb6558771a19969/ruamel.yaml-0.15.46-cp27-cp27m-win_amd64.whl (208kB)
100% |################################| 215kB 1.7MB/s
Collecting ruamel.ordereddict; platform_python_implementation == "CPython" and python_version <= "2.7" (from ruamel.yaml)
Downloading https://files.pythonhosted.org/packages/2b/d4/b1ec24d4cc8669bb01e303573a5dd9a85b4c116a53c225749fbb9bce0ac9/ruamel.ordereddict-0.4.13-cp27-cp27m-win_amd64.whl
Installing collected packages: ruamel.ordereddict, ruamel.yaml
Successfully installed ruamel.ordereddict-0.4.13 ruamel.yaml-0.15.46
(so_51581941) $ pip freeze
ruamel.ordereddict==0.4.13
ruamel.yaml==0.15.46
(so_51581941) $ python -c "import ruamel.yaml"
(so_51581941) $ deactivate
$
(即来自commmand.com
with set prompt=$$
)
推荐阅读
- oauth-2.0 - 邮递员没有保存新的 OAuth 2.0 访问令牌
- python - 使用 AWS LAMBDA 删除旧的手动集群快照 RDS
- python - python:for循环错误中的Input()
- c++ - 我不能在循环中使用 spdlog 记录器
- java - Android NDK 项目:java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader
- android - ConstraintLayout AutoTransition 动画不起作用
- c - stdio 是否将文件描述符偏移设置回文件关闭时的下一个未读位置?
- vim - 当文本隐藏在 nowrap 下时,转到实际的行尾
- python - 链表结构中的迭代问题
- node.js - 防止快递中的默认响应