Spyder как установить библиотеку
Перейти к содержимому

Spyder как установить библиотеку

Installation Guide¶

Spyder is relatively easy to install on Windows, Linux and macOS. Just make sure to read and follow these instructions with care.

If you run into problems, before posting a report, please consult our comprehensive troubleshooting guide and search the issue tracker for your error message and problem description. These methods generally fix or isolate the great majority of install-related difficulties. Thanks!

Spyder now offers standalone installers for Windows and macOS, making it easier to get up and running with the application without having to download Anaconda or manually install it in your existing environment. While we still support Anaconda, we recommend this install method on those platforms to avoid most problems with package conflicts and other issues.

Try Spyder online¶

Want to try out Spyder without installing it? With Binder you can work with a fully functional copy of Spyder online that runs right in your web browser, no installation needed. Just visit the Spyder page on Binder to get started using Spyder now.

Spyder running on Binder

Standalone installers¶

Our standalone installers for Windows and macOS are available from Spyder 4.2 onwards. We recommend using this installation method on those platforms, but we offer several other options for Linux, advanced users and specific needs, so keep reading if that’s the case for you.

Downloading and installing¶

To download the supported Spyder installer for your platform, simply click the appropriate link below. (For Linux, see the Anaconda section). Then, double-click the downloaded file to open the installer. If a security warning pops up, you may need to click Yes , OK , Open , Allow or similar.

On Windows, if a SmartScreen dialog appears, click More info followed by Run anyway , and then proceed through the steps in the installer.

On macOS, open the disk image and drag Spyder to your Applications folder.

“Lite” versions of both installers are also available from the releases page, which are somewhat smaller than the full installers. These lack a number of optional but recommended dependencies, such as NumPy, SciPy and Pandas, meaning that a few Variable Explorer features, including graphical data import wizards and support for rich display and editing of NumPy arrays and Pandas DataFrames, will not be available. Given this only saves a modest amount of space while missing out on significant features, we recommend using the full installers unless minimizing download/install size and memory usage is a priority.

Running from a standalone install¶

To run Spyder when installed standalone, you can simply use your operating system’s typical method of launching applications, such as opening it from the Start menu on Windows (or the Taskbar, if you’ve pinned it there), or from Launchpad, Spotlight or the Applications folder on macOS (or the Dock, if you’ve added it there).

On macOS, the first time you open Spyder, you may see a message that it cannot be opened because the developer cannot be verified. If so, right-click on the application, select Open , then click Open in the resulting dialog, and the warning will no longer be shown. You can also click Open Anyway under Security & Privacy ‣ General in System Preferences.

For more information on installing your own packages and using standalone Spyder with your existing Python environments, see our FAQ .

Anaconda¶

Spyder is included by default in the Anaconda Python distribution, which comes with everything you need to get started in an all-in-one package, and is our recommended installation method on Linux (and supported on the other platforms too).

Running with Anaconda¶

To run Spyder after installing it with Anaconda, the recommended method on Windows is to launch it via the Start menu shortcut. On other platforms, open Anaconda Navigator, scroll to Spyder under Home , and click Launch .

Anaconda Navigator showing Spyder

If Spyder does not launch via this method or you prefer to use the command line, open Anaconda Prompt (Windows) or your terminal (other platforms), type conda activate base then spyder .

New Conda environment¶

If you would like to have Spyder in a dedicated environment to update it separately from your other packages and avoid any conflicts, you can. Just run the following command in your Anaconda Prompt (Windows) or terminal (other platforms), for a minimal install of Spyder into a new environment called spyder-env :

To install Spyder’s optional dependencies as well for full functionality, use the following command instead:

To install Spyder from Conda-Forge instead of the default Anaconda channel, add -c conda-forge at the end of either of the previous commands.

You can then run Spyder by the same methods as above, except make sure to select the start menu shortcut with (spyder-env) in the name, select the spyder-env environment on the left before launching it with Navigator, or type conda activate spyder-env before launching it on the command line.

For more information on this approach, and using Spyder with your existing Python environments and packages, please see our Guide to working with packages and environments in Spyder.

Alternative methods¶

While we offer alternative Spyder installation options for users who desire them, we currently lack the resources to offer individual assistance for problems specific to installing via these alternative distributions. Therefore, we recommend you switch to our standalone installers (Windows and macOS) or Anaconda if you encounter installation issues you are unable to solve on your own.

Windows¶

Spyder is included in the WinPython scientific Python distribution (although Anaconda’s conda package and environment manager is not). You can use Spyder immediately after installing, just like with Anaconda.

macOS¶

Thanks to the MacPorts project, Spyder can be installed using its port package manager; however, the included Spyder version may be out of date or have MacPorts-specific issues outside of Spyder’s control.

There are several versions available from which you can choose.

Linux¶

Distribution packages are created by third parties, are often outdated relative to the current Spyder release, and may contain bugs and be missing features relative to the current supported version. As such, given we are not able to provide official support for them, we strongly recommend using Anaconda on Linux whenever practical (or pip , for advanced users).

Spyder can be installed via third-party distro packages on most common Linux distributions.

Running Spyder installed this way will generally be the same as any other distro-installed application. Alternatively, it can be launched from the terminal with spyder (or spyder3 , on older versions of some distros).

Working with packages and environments in Spyder

While relatively straightforward once you’re familiar with it, the interaction between Spyder and other packages and environments can sometimes be confusing for first-time users. Improvements to Spyder have made this process much easier (and there is more to come!), but we’d like to clarify how that relationship works.

We’ll start by helping you to debug a common problem encountered in Python when dealing with packages and environments, i.e. when you can’t import a module even if you’re sure that you’ve installed it. Next, we’ll guide you through setting up your Spyder environment(s) to improve your workflow. If you’re looking for a way to use Spyder with different environments (e.g. one for simple data analysis, one for machine learning, one for developing an app, etc.) you can go directly to the final section.

The most common problem: Using newly-installed packages inside Spyder

After installing a package (let’s call it foo ) outside Spyder, users may encounter an error trying to import it inside the IDE:

This happens because foo was installed (with either conda or pip ) in a different conda or venv/virtualenv environment than the one in which Spyder is currently running.

To confirm this is the problem, you need to:

Activate the environment (e.g. myenv ) in which you installed the package foo (e.g. with conda activate myenv for conda, source myenv/bin/activate or workon myenv for virtualenv/venv, etc.).

Start a Python interpreter there by running the command python .

Run the following command inside the Python interpreter:

Start Spyder and run the same command shown in Step 3 in a Console.

If the resulting paths are the same, then Spyder and the package are in the same environment, and import foo shouldn’t produce an error (or else there is likely an unrelated issue with your installation).

If the resulting paths are different, then you have three choices:

  • Activate the environment in which Spyder is installed and install your package on it (see next section). If you try to install future packages in another environment (like myenv ), you’ll get the same ModuleNotFoundError .
  • Install Spyder into the existing myenv environment, or any other you’d like to work in, and run it from there (see following section). This is a little simpler than the third option and has the same effect, but more overhead and is less flexible.
  • Install just the spyder-kernels package into the myenv environment, and set your Python interpreter path in Spyder’s Preferences to point to myenv ‘s Python executable (see the final section. This requires one more initial step, but requires less maintenance in the long run and avoids duplicate Spyder installs.

Installing packages into the same environment as Spyder

Spyder is a Python package just like any other you may be used to, and so you can import any package within its Console or Editor as you could from a regular Python or IPython terminal launched in Spyder’s environment:

  • If Spyder is installed via our standalone installers (as we recommend on Windows and macOS), this will be Spyder’s built-in environment, which contains many popular scientific package, but cannot be modified, to avoid breaking Spyder itself.
  • If Spyder is installed with Anaconda (as we recommend on Linux) and launched via a shortcut, from Anaconda Navigator or from Anaconda Prompt without modifying anything, this will be the default base Anaconda environment.
  • If Spyder is installed via pip (experts only) and not into a virtualenv / venv , this will usually be whatever Python installation pip itself belongs to.
  • If you use a system package manager ( apt-get , dnf , emerge , etc) to install Spyder, this will typically be your system Python and its library of packages.
  • If you installed Spyder into a specific environment ( conda-env or venv ), or it came with a pre-configured one (like those for Keras or TensorFlow) and launched it from there, it will only have access to packages from that environment.

Therefore, if you’d like to use a package with your existing Spyder install (e.g. importing it into your scripts, packages or a Spyder IPython console), the simplest way to do so is to install the package into the same environment in which you installed Spyder, typically by the same means you installed Spyder ( conda , pip , package manager, etc). However, this is not possible if you’ve used a standalone installer, and if you’re installing packages with pip , conda-forge , Github, or custom channels, working on multiple major projects at once, using prebuilt environments, or otherwise have more sophisticated needs, you’ll likely want to use one or more separate environments for your packages. If so, the next section explains how.

Working with other environments and Python installations

If you have an existing, pre-configured environment (such as for Keras or TensorFlow), are managing multiple environments (such as for development or testing purposes), or even would like to work within a totally separate Python installation as that in which Spyder is installed (such as a standalone installer Spyder with a separate Anaconda installation, or vice-versa), you can install the modular spyder-kernels package into any Python environment ( conda environment, virtualenv/venv , system Python, WinPython, etc) in which you wish to work, and then change the Python interpreter used by Spyder on its IPython consoles to point to the Python executable of that environment.

This takes a small amount of preparation and configuration, but is much «lighter» and quicker than a full Spyder installation into that environment, avoids dependency conflicts, and opens up new workflow possibilities.

To achieve this, follow these steps:

Activate the environment (e.g. myenv ) in which you’d like to work (e.g. with conda activate myenv for conda, source myenv/bin/activate or workon myenv for virtualenv/venv, etc)

Install the spyder-kernels package there, with the command:

conda install spyder-kernels if using conda/Anaconda,

pip install spyder-kernels if using pip/virtualenv.

After installing via either method, run the following command inside the same environment:

and copy the path returned by that command (it should end in python , pythonw , python.exe or pythonw.exe , depending on your operating system).

Deactivate that environment, activate the one in which Spyder is installed (if you’ve installed it in its own environment) and start Spyder as you normally would.

After Spyder has started, navigate to Preferences > Python Interpreter > Use the following interpreter and paste the path from Step 3 into the text box.

Start a new IPython console. All packages installed in your myenv environment should be available there. If conda is used, the name of the current environment and its Python version should be displayed in Spyder’s status bar, and hovering over it should display the path of the selected interpreter.

Notes:

  • In order for the Variable Explorer to be able display the built-in editors for specific data types (Numpy array, Pandas Series/DataFrame, etc) the corresponding optional Spyder dependencies (Numpy, Pandas, etc) need to be installed in Spyder’s environment, not just the IPython console working env. Furthermore, this is currently also required for custom classes provided by third-party packages displayed in the Object Explorer, though future Spyder versions may remove this latter limitation.
  • While Spyder should work fine without it, ensuring the Python minor version ( 3.6 , 3.7 , 3.8 , etc) in Spyder’s environment matches that in your working environment, if practicable, will minimize the chance of any issues.

Be Social

Connect with Spyder through our social media channels and stay up to date with current developments!

Добавление модуля (в частности, pymorph) в Spyder (Python IDE)

Мне удалось установить и заставить работать spyder на моем mac, но я хочу добавить несколько модулей, которые он не включает по умолчанию (mahotas и pymorph).

Я установил оба модуля через easy_install в терминале, и они установились без каких-либо сообщений об ошибках. Запуск python из терминала и использование import mahotas и import pymorph работает просто отлично без сообщений об ошибках. Однако, когда я запускаю те же строки из сценария в spyder, я получаю следующую ошибку:

Все, что я сейчас пытаюсь сделать, это запустить строки импорта, и все. Я не могу найти ничего об этом. Я предполагаю, что spyder использует отдельную установку python и что установка модулей через терминал устанавливает их только в системную версию python. Как мне добавить их в spyder?

Specs:

Импорт собственных модулей в Python. Import modules. Атрибут модуля __name__ и __main__

Уроки Python / Модуль datetime

Python. Как установить библиотеки? | Записки программиста

55 Установка модулей в Python || Установка пакета Python || Установка библиотеки в python

Основы Python #16: импорт модулей

Модули sys и os

Уроки Python для начинающих | #16 - Модули. Работа с import и from

Разработка модуля ввода на Python

Импорт модулей. Функция reload. Как перезагрузить модуль в Python

Уроки Python - Модули

Модули. Импорт стандартных модулей в Python. Команды import и from Python. Импорт модулей Python

#6 PYTHON: ��МОДУЛИ/МОДУЛЬ MATH

Пишем свой ЯП на Python #1 - Написание установщика модуля Uranium

Знакомство с модулем Turtle | Программирование на Python

TOP-3 IDE для программирования на Python | Базовый курс. Программирование на Python

Ок, никто еще не ответил на этот вопрос, но мне удалось разобраться и заставить его работать после того, как я также написал на дискуссионной доске spyder. Для всех библиотек, которые вы хотите добавить и которые не включены в путь поиска по умолчанию в spyder, вам нужно зайти в Tools и добавить путь к каждой библиотеке через менеджер PYTHONPATH. Затем вам нужно будет обновить список имен модулей из того же меню и перезапустить spyder, чтобы изменения вступили в силу.

Через ! на консоли оболочкой IPython в спайдере позволяет использовать типун . Так, в примере, вы могли бы сделать:

Заметим, что это также доступно (хотя, возможно, неверным) в консоли Python для Спайдера версии до

2.3.3. Спасибо @CarlosCordoba за это уточнение.

Найдите местоположение модуля в терминале:

Скопируйте-вставьте папку модуля в папку ‘Spyder.app/Contents/Resources/lib/python2.7’

Если вы используете Spyder в пакет Анаконда.

В консоли оболочкой IPython, использовать

Это работает локально.

Примечание:! необходим при использовании консоли оболочкой IPython в Спайдере.

просто использовать '!' перед командой PIP в терминал спайдер и это будет нормально

João Almeida

Вы можете добавить местоположение стандартной установки в менеджер PYTHONPATH. Таким образом, вам не нужно будет добавлять отдельный путь для каждого модуля. Только для обновления имен модулей.

На Unix это место обычно:

Я столкнулся с той же проблемой при попытке добавить Сиборн модуль в Спайдере. Я установил Сиборн в моем каталоге Анаконда в Ubuntu 14.04. В Сиборн модуль будет загружаться, если я добавил всю анаконда/Либ/вместо python2.7/сайт-пакеты/ каталог, в котором содержатся 'Сиборн' и Сиборн-0.5.1-py2.7.папки яйцо-инфо. Проблема этого сайта-пакеты анаконда папке содержатся также многие другие модули, которые Спайдер не понравился.

Мое решение: Я создал новый каталог в моей личной домашней папки, которую я назвал 'spyderlibs', куда я поместил Сиборн и Сиборн-0.5.1-py2.7.папки яйцо-инфо. Добавлять мой новый каталог spyderlib в Spyder'менеджер с PYTHONPATH работал!

Можно также выполнить следующие действия : Спайдер -и gt; Инструменты -> открыть командную строку -> написать команда «типун установить html5lib и»

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *