Как исправить: нет модуля с именем seaborn
Одна распространенная ошибка, с которой вы можете столкнуться при использовании Python:
no module named ' seaborn '
Эта ошибка возникает, когда Python не обнаруживает морскую библиотеку в вашей текущей среде.
В этом руководстве представлены точные шаги, которые вы можете использовать для устранения этой ошибки.
Шаг 1: pip устанавливает Seaborn
Поскольку Seaborn не устанавливается автоматически вместе с Python, вам нужно будет установить его самостоятельно. Самый простой способ сделать это — использовать pip , менеджер пакетов для Python.
Вы можете запустить следующую команду pip для установки Seaborn:
pip install seaborn
В большинстве случаев это исправит ошибку.
Шаг 2: Установите пип
Если вы все еще получаете сообщение об ошибке, вам может потребоваться установить pip. Используйте эти шаги , чтобы сделать это.
Вы также можете использовать эти шаги для обновления pip до последней версии, чтобы убедиться, что он работает.
Затем вы можете запустить ту же команду pip, что и раньше, чтобы установить seaborn:
pip install seaborn
На этом этапе ошибка должна быть устранена.
Шаг 3. Проверьте версии Seaborn и Pip.
Если вы все еще сталкиваетесь с ошибками, возможно, вы используете другую версию seaborn и pip.
Вы можете использовать следующие команды, чтобы проверить, совпадают ли ваши версии Seaborn и Pip:
which python python --version which pip
Если две версии не совпадают, вам необходимо либо установить более старую версию Seaborn, либо обновить версию Python.
Шаг 4: Проверьте версию Seaborn
После того, как вы успешно установили Seaborn, вы можете использовать следующую команду, чтобы отобразить версию Seaborn в вашей среде:
pip show seaborn Name: seaborn Version: 0.11.2 Summary: seaborn: statistical data visualization Home-page: https://seaborn.pydata.org Author: Michael Waskom Author-email: mwaskom@gmail.com License: BSD (3-clause) Location: /srv/conda/envs/notebook/lib/python3.7/site-packages Requires: numpy, scipy, matplotlib, pandas Required-by: Note: you may need to restart the kernel to use updated packages.
Примечание. Самый простой способ избежать ошибок с версиями Seaborn и Python — просто установить Anaconda , набор инструментов, предустановленный вместе с Python и Seaborn и бесплатный для использования.
Дополнительные ресурсы
В следующих руководствах объясняется, как исправить другие распространенные проблемы в Python:
Installing and getting started#
Official releases of seaborn can be installed from PyPI:
pip install seaborn
The basic invocation of pip will install seaborn and, if necessary, its mandatory dependencies. It is possible to include optional dependencies that give access to a few advanced features:
pip install seaborn[stats]
The library is also included as part of the Anaconda distribution, and it can be installed with conda :
conda install seaborn
As the main Anaconda repository can be slow to add new releases, you may prefer using the conda-forge channel:
conda install seaborn -c conda-forge
Dependencies#
Supported Python versions#
- Python 3.8+
Mandatory dependencies#
Optional dependencies#
- statsmodels, for advanced regression plots
- scipy, for clustering matrices and some advanced options
- fastcluster, faster clustering of large matrices
Quickstart#
Once you have seaborn installed, you’re ready to get started. To test it out, you could load and plot one of the example datasets:
import seaborn as sns df = sns.load_dataset("penguins") sns.pairplot(df, hue="species")
If you’re working in a Jupyter notebook or an IPython terminal with matplotlib mode enabled, you should immediately see the plot . Otherwise, you may need to explicitly call matplotlib.pyplot.show() :
import matplotlib.pyplot as plt plt.show()
While you can get pretty far with only seaborn imported, having access to matplotlib functions is often useful. The tutorials and API documentation typically assume the following imports:
import numpy as np import pandas as pd import matplotlib as mpl import matplotlib.pyplot as plt import seaborn as sns import seaborn.objects as so
Debugging install issues#
The seaborn codebase is pure Python, and the library should generally install without issue. Occasionally, difficulties will arise because the dependencies include compiled code and link to system libraries. These difficulties typically manifest as errors on import with messages such as «DLL load failed» . To debug such problems, read through the exception trace to figure out which specific library failed to import, and then consult the installation docs for that package to see if they have tips for your particular system.
In some cases, an installation of seaborn will appear to succeed, but trying to import it will raise an error with the message «No module named seaborn» . This usually means that you have multiple Python installations on your system and that your pip or conda points towards a different installation than where your interpreter lives. Resolving this issue will involve sorting out the paths on your system, but it can sometimes be avoided by invoking pip with python -m pip install seaborn .
Getting help#
If you think you’ve encountered a bug in seaborn, please report it on the GitHub issue tracker. To be useful, bug reports must include the following information:
- A reproducible code example that demonstrates the problem
- The output that you are seeing (an image of a plot, or the error message)
- A clear explanation of why you think something is wrong
- The specific versions of seaborn and matplotlib that you are working with
Bug reports are easiest to address if they can be demonstrated using one of the example datasets from the seaborn docs (i.e. with load_dataset() ). Otherwise, it is preferable that your example generate synthetic data to reproduce the problem. If you can only demonstrate the issue with your actual dataset, you will need to share it, ideally as a csv.
If you’ve encountered an error, searching the specific text of the message before opening a new issue can often help you solve the problem quickly and avoid making a duplicate report.
Because matplotlib handles the actual rendering, errors or incorrect outputs may be due to a problem in matplotlib rather than one in seaborn. It can save time if you try to reproduce the issue in an example that uses only matplotlib, so that you can report it in the right place. But it is alright to skip this step if it’s not obvious how to do it.
General support questions are more at home on stackoverflow, where there is a larger audience of people who will see your post and may be able to offer assistance. Your chance of getting a quick answer will be higher if you include runnable code, a precise statement of what you are hoping to achieve, and a clear explanation of the problems that you have encountered.
How do you update seaborn to latest version (v0.9)?
This is my first question 😐 I am currently running seaborn version 0.8.1 in Python3. How do I update to v0.9?
asked Sep 21, 2018 at 0:01
136 1 1 gold badge 1 1 silver badge 8 8 bronze badges
Sep 21, 2018 at 0:52
1 Answer 1
Many ways you could do it, the most succinct and straight-forward way may be:
pip install seaborn --upgrade
If that doesn’t give you the correct version, you can specify it explicitly:
pip install seaborn==0.9.0
answered Sep 21, 2018 at 0:41
chickity china chinese chicken chickity china chinese chicken
7,779 2 2 gold badges 20 20 silver badges 50 50 bronze badges
- python-3.x
- seaborn
-
The Overflow Blog
Linked
Related
Hot Network Questions
Subscribe to RSS
Question feed
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2024 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2024.1.3.2953
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Python 3: Как узнать версию библиотеки Pandas, Numpy
Вариант 1. Узнаем версию библиотеки в скрипте Python
Для того, чтобы узнать версию библиотеки, необходимо вбить следующую команду (например для Pandas):
import pandas as pd print (pd.__version__)
Пример для Numpy:
import numpy as np print (np.__version__)
Вариант 2. Проверить с помощью pip менеджера пакетов
С помощью менеджера пакетов pip можно проверить версию установленных библиотек, для этого используются команды:
- pip list
- pip freeze
- pip show pandas
pip list
Выведет список установленных пакетов, включая редактируемые.
Пишем в консоли команду:
pip list
Результат:

pip freeze
Выводит установленные пакеты, которые ВЫ установили с помощью команды pip (или pipenv при ее использовании) в формате требований.
Вы можете запустить: pip freeze > requirements.txt на одной машине, а затем на другой машине (в чистой среде) произвести инсталляцию пакетов: pip install -r requirements.txt .
Таким образом вы получите идентичную среду с точно такими же установленными зависимостями, как и в исходной среде, в которой вы сгенерировал файл requirements.txt.
Результат:

pip show
Выводит информацию об одном или нескольких установленных пакетах.
Пример:
pip show pandas
Результат:

Anaconda — conda list
Если вы используете Anaconda, то вы можете проверить список установленных пакетов в активной среде с помощью команды conda list .