import package in Spyder, Python

Asked

Viewed 2,222 times

2

I’m starting to learn python. So the first thing I did was to install python, in this case Ubuntu 16.04 LTS, since in this system python is already installed.

As a first test, I tried running a simple program with the library numpy, but the n program runs, displays the following error:

import sitecustomize' failed; use -v for traceback
<type 'numpy.ndarray'>

It seems Spyder failed to import the library numpy, although I have already called her by the terminal and she came, ie, is installed.

My script is as follows:

# -*- coding: utf-8 -*-
"""
Created on Tue Jan 22 07:58:47 2019

@author: David
"""

import numpy as np
a = np.array([1, 2, 3])   
print(type(a))    

Would someone please help me with this problem? I thank you in advance.

  • 1

    You should have installed Ubuntu 18.04 LTS since 16.04 is old and has almost 3 years since it was launched. Your problem seems to be the way you are running the script. Try opening a terminal and running the script directly in python by typing python meuscript.py

  • It is - Ubuntu has a new version every 6 months, and Python has a version with big changes every 18 months. If you are going to install a system only for Python, put the newest one - Ubuntu 18.10 (and even this one comes with version 3.6 of Python, already outdated).

  • Then worry about the language, not an IDE - until you’re familiar with the language

  • And finally, see rent tutorial on "virtualenv" - and how to create isolated Python environments with several different versions and libraries, according to each project.

  • thanks for the suggestions friend.

  • Friend, the numpy import you made was by Ubuntu terminal or was by the console the Ipython in Spyder.

Show 1 more comment

1 answer

1

Good night,

Your problem is not affected by the version of your Ubuntu, the fact that should be seen is which interpreter your Spyder is using. Most distros come with python by default, I never found one that didn’t come with python, when installing numpy by the terminal it will be available for your interpreter.

But if you have used the Anaconda for example to install the Spyder it ends up using the interpreter of Anaconda, which is different from your interpreter of your OS, ie you end up having two python consoles with the same summer however different.

If you want to see if numpy is installed in the same Spyder interpreter just import in the Ipython console in Spyder itself.

Ipython

If you want to change the default Spyder interpreter just go to Ferramentas -> Preferências(Ctrl + Alt + Shift + P) -> Interpretador Python and select the desired Interpreter.

Interpretador

Browser other questions tagged

You are not signed in. Login or sign up in order to post.