简体   繁体   中英

Error when using numpy module in Sublime Text

I am trying to set up and use numpy on sublime text. However, it marks the numpy instructions as syntax errors.

If I type out something simple like below ,

import numpy as np
print np.pi,np.e
x= np.random.random(10)
print(x)

Running this file from the terminal works fine and I get the desired result as -

Dabbling with Python python Linear-Regression.py

3.14159265359 2.71828182846
[ 0.89299598  0.95393114  0.52340898  0.93117159  0.71658433  0.62331653
  0.60741025  0.92175348  0.99218785  0.94231719]

However, on sublime text I get errors on lines 2 and warnings on all other lines.

Error - Module 'numpy' has no 'pi' member; Module 'numpy' has no 'e' member.

I have installed plugin anaconda and pylinter

Check which python version is being called when you run your script from the command line and copy the path, ie which python . Edit your Python.sublime-build file:

{
    "shell_cmd": "python -u \"$file\"",
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}

and replace python on the first line with the path you just copied.

  1. install cmder from https://cmder.net/
  2. run cmder
  3. type this code pip install XXXX

just replace your package name with " XXXX ".

for example: pip install numpy

you can install other packages with this way:))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM