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

Как установить библиотеку в спайдер

  • автор:

How to update Python missing libraries on Spyder — via the Console Area using Conda.

Norberto CIOFFI

Like many, when using Spyder to write and run Python scripts, I do miss some libraries not included in the standard setup.

Normally all the updates are downloaded and installed via the pip command[1]. But it could happen anyway that local developing environments are not immediately linked with Python, determining in fact that libraries are not visible on Spyder. In a past article, I described a fast workaround on how to force this process — link here[2].

Anyway, a more stable and comprehensive method can be done by installing the missing libraries via Conda, by using the Console Area on the developing application.

How? No worries, really of a piece of cake [3].

For example, let’s try to install the moviepy [4] library — a set of functions developed for video editing on Python.

As you can see, I do have Spyder version 4.1.4. Also, take a look at the image to identify the Script Area (on the left) and the Console Area (on the right):

While running the script, in the Console Area appears the missing module error message:

So, let’s go on the web and find the Anaconda page containing the linecode(s) to run conda procedure:

Now on the Spyder Console Area let’s type the 1st command line found, adding at the beginning an exclamation point “!” and at the end “- — y” + ENTER:

!conda install -c conda-forge moviepy — — y (+ ENTER)

It may take few minutes but as you can check here below the installation will be executed:

Hoping this will help people who got stuck as I was a few afternoons ago, while outside it was a sunny day and a perfect opportunity for a walk around. Bye 🙂

Pip установить в Spyder

Я использую Python 3.6 через Spyder в Anaconda3. У меня есть установка Anaconda и «чистая» установка python.

Прежде чем я установил «чистый» python, когда я запустил команду Python -V в cmd, я получил следующее описание версии. Python 3.6.5 :: Anaconda, Inc. Теперь, когда я запускаю команду, он просто говорит Python 3.6.5. и pip list намного короче.

Когда я когда-либо открываю Spyder и нахожу какой-то пакет, который у меня нет. как я могу поучаствовать в установке пакета? Если я просто открою cmd и напишу pip install. он будет установлен в «чистый» каталог python. Как мне сказать, чтобы подключиться к Spyder?

3 ответа

Как вы можете видеть в этом сообщении, есть некоторая разница между pip и conda .

Используя среду Anaconda вы должны использовать команду conda для установки вашей библиотеки, пакета и т.д.

Я знаю, что это очень поздний ответ, но он может помочь другим людям. Когда вы работаете с Anaconda, вы можете использовать базовую среду или создать новую (это может быть то, что вы называете «чистой» установкой Python). Для этого просто сделайте следующее:

  • Открой тебе анаконду навигатор
  • Перейти в «Среды»
  • Нажмите на кнопку создать. Здесь, кстати, вы можете выбрать версию Python

Затем для установки вашей библиотеки вы можете использовать графический интерфейс Anaconda:

  • Двойной щелчок на вашей среде
  • На правой стороне у вас есть все, что вы установили lib. В списке выберите «Не установлено»
  • Найдите свою библиотеку, проверьте ее и нажмите «применить» в правом нижнем углу

Вы также можете сделать это в консоли Windows (CMD), я предпочитаю этот способ (больше доверия, и вы можете видеть, что происходит):

  • Откройте консоль
  • conda activate yourEnvName
  • conda install -n yourEnvName yourLib
  • Только если ваша pip install yourLib не нашла вашу pip install yourLib сделайте pip install yourLib
  • В конце conda deactivate

/!\Если вы используете этот способ, закройте свой графический интерфейс Anaconda, пока вы делаете это

Если вы хотите, вы можете найти свою среду в (в Windows) C:\Users\XxUserNamexX\AppData\Local\Continuum\anaconda3\envs. Каждая папка будет содержать библиотеку для названной среды.

Надеюсь, это будет полезно

PS: обратите внимание, что важно запустить spyder через графический интерфейс Anaconda, если вы хотите, чтобы Spyder нашел вашу библиотеку

Instagram

If you are same as me, you probably love to work with Python because of it’s versatility and open-source. Since I was participated on some Python projects I started to do more in Python than in MATLAB as I did before. But I like clean solutions.

There are tons of tutorials how to install Python2/3 on macOS, how to install Anaconda and Spyder etc. I found the Spyder IDE as best to fit my needs. It is very similar to MATLAB so you won’t loose your learned skills as it is decribed here.

First it will only work for Python 3.5 so if you need for some dependecy reasons use Python 2.7.x or Python 3.x.x this tutorial is not going to work. Download Spyder from Github releases page.

When you run Spyder and try to import some unusuall liberary you should get error that there is no module named like that. For importing mne module i got this out-of-the-box.

So we need to download our library. One way (it is not described in here) is to download a ZIP file from Github or the library page at store them somewhere on your drive. Or download Python 3.6 on Python website.

After you install Python 3.6. Open terminal and enter which python3 , you should end up with something like this

. This means that Python 3.6 is successfully instaleld on your drive. Then you can use a regular way to install packages via pip.

After installing the mne module by entering `pip3 install mne` in terminal I have installed my module in my Python distribution. I need to know where the Python3 stores a so called site-packages (library of packages). I can be done very easily by

It returns something like this:

So this is our desired location where python stores all liberaries.

Snímek obrazovky 2017-05-17 v 21.50.56.png

After that open Spyder settings > iPython console > startup tab > and start to write in Lines collumn.

import sys, sys.path.append(“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages”)

Of course you have to enter your path to append your site-package at the start.

Как установить библиотеку в спайдер

(Apr-29-2017, 11:04 AM) awa5114 Wrote: I don’t really want to change the working directory. I want to see if there is a way to preserve the working directory but add a path variable to an additional directory.

The reason is that if I change the working directory I might lose access to some of the other libraries that are in it.

Where can I see all the modules available to me in Spyder? Is there a list somewhere?

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

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