Archivo de la etiqueta: python

Use BeautifulSoup with Spyder

[programming]

I have been trying various IDE for working with Python on my Mac and I have finally decided for using Spyder. I would be using Ninja IDE since I had previous experience with it in Windows and Linux, but for whatever reason, it has no compiled build for Mac, and I was not in the mood to try and build it myself from source code, so I’m going with Spyder.

I’m linking it quite a bit. Al least for the simple projects I’m working on it’s more than enough. I’m also using the BeautifulSoup library to extract web page info, and after following the installation instructions in it’s web page, my script in Spyder did not find the library.

After a little research, problems seems to be that Spyder uses it’s own version of Python, so it could not detect the Python libraries I had installed. To solve it, we have to tell Spyder to use the Python we have installed. We go to:

Spyder -> Preferences… -> Console -> Advanced settings

Then we select the Use the following Python interpreter option, and in my case, the path is /usr/bin/python

Usar BeautifulSoup con Spyder

[programación]

He estado mirando varios IDE para Python en Mac y al final me he decidido por usar Spyder. Habría usado Ninja IDE porque ya lo he usado anteriormente en Linux y Windows y me gusta bastante, pero por algún motivo no ofrecen una versión compilada para Mac, y no tenía ganas de ponerme a hacerlo funcionar desde el código fuente, así que estoy probando Spyder.

De momento me está gustando bastante. Al menos para las cosas sencillas que estoy haciendo es suficiente. Estoy usando la librería BeautifulSoup para extraer información de páginas web y aunque la había instalado siguiendo las instrucciones en su web, al lanzar el script de Python no la estaba encontrando.

Tras investigar como utilizar BeautifulSoup con Spyder, el problema consiste en que Spyder utiliza su propio Python que trae integrado, por lo que no detecta las librerías instaladas en el Python del Mac. Para solucionarlo hay que indicar que debe usar el Python del Mac en la configuración de Spyder. Para ello vamos a:

Spyder -> Preferences… -> Console -> Advanced settings

Seleccionamos la opción Use the following Python interpreter: y en mi caso la ruta es /usr/bin/python