如何为我的PyCharm Python项目安装yaml软件包?

时间:2019-01-23 21:30:02

标签: python django python-3.x pycharm yaml

我正在将PyCharm 2018.2.4与Python 3.7一起使用。我想运行一些种子数据,因此在Python管理控制台中,我尝试运行yaml文件,该文件以此错误结尾

manage.py@mainpage_project > loaddata seed_data
bash -cl "/Users/davea/Documents/workspace/mainpage_project/venv/bin/python /Applications/PyCharm.app/Contents/helpers/pycharm/django_manage.py loaddata seed_data /Users/davea/Documents/workspace/mainpage_project"
Tracking file by folder pattern:  migrations
/Users/davea/Documents/workspace/mainpage_project/venv/lib/python3.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
  """)
Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/helpers/pycharm/django_manage.py", line 52, in <module>
    run_command()
  File "/Applications/PyCharm.app/Contents/helpers/pycharm/django_manage.py", line 46, in run_command
    run_module(manage_file, None, '__main__', True)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/davea/Documents/workspace/mainpage_project/manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/davea/Documents/workspace/mainpage_project/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/Users/davea/Documents/workspace/mainpage_project/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/davea/Documents/workspace/mainpage_project/venv/lib/python3.7/site-packages/django/core/management/base.py", line 316, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/davea/Documents/workspace/mainpage_project/venv/lib/python3.7/site-packages/django/core/management/base.py", line 353, in execute
    output = self.handle(*args, **options)
  File "/Users/davea/Documents/workspace/mainpage_project/venv/lib/python3.7/site-packages/django/core/management/commands/loaddata.py", line 72, in handle
    self.loaddata(fixture_labels)
  File "/Users/davea/Documents/workspace/mainpage_project/venv/lib/python3.7/site-packages/django/core/management/commands/loaddata.py", line 113, in loaddata
    self.load_label(fixture_label)
  File "/Users/davea/Documents/workspace/mainpage_project/venv/lib/python3.7/site-packages/django/core/management/commands/loaddata.py", line 165, in load_label
    ser_fmt, fixture, using=self.using, ignorenonexistent=self.ignore,
  File "/Users/davea/Documents/workspace/mainpage_project/venv/lib/python3.7/site-packages/django/core/serializers/__init__.py", line 140, in deserialize
    return d(stream_or_string, **options)
  File "/Users/davea/Documents/workspace/mainpage_project/venv/lib/python3.7/site-packages/django/core/serializers/__init__.py", line 50, in __call__
    raise self.exception
  File "/Users/davea/Documents/workspace/mainpage_project/venv/lib/python3.7/site-packages/django/core/serializers/__init__.py", line 70, in register_serializer
    module = importlib.import_module(serializer_module)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/davea/Documents/workspace/mainpage_project/venv/lib/python3.7/site-packages/django/core/serializers/pyyaml.py", line 11, in <module>
    import yaml
ModuleNotFoundError: No module named 'yaml'

so then I opened up my Project Interpreter page, selected the "yaml" module and clicked "Install".  However it didn't install and instead gave me this error ...

收集Yaml

  Could not find a version that satisfies the requirement yaml (from versions: )
No matching distribution found for yaml

如何安装Yaml for PyCharm?

2 个答案:

答案 0 :(得分:1)

我认为您正在寻找pyyaml

https://pypi.org/project/PyYAML/

答案 1 :(得分:0)

如果要通过Pycharm而不是终端安装任何模块。有关此信息,请参阅屏幕截图:-

For example, you need to install numpy