Using Anaconda plug-in in SublimeText 3 I do not get available methods for a variable.
Should I expect this from Anaconda or is it not a feature?
import numpy as np
x = np.linspace(0,10) # Autocompletion works fine
x. # Autocompletion does not show available methods
Related
I am working with algebraic expressions in Python.
I would like to know if exists any VS Code extension to automatically view expressions in a more human-friendly way.
For example:
x*y*math.e**(-x**2-y**2)
I have used below two mainly for mathematical expressions:
Symplex:
Symplex requires that Python and SymPy are installed. It can be installed with pip install SymPy.
Numpy: Why Numpy? Because of algebraic-expressions-in-python are best sorted by Numpy. However, Numpy extension on VS code is also not straightforward. Check please following SO sources for you to get Numpy in your VS code:
No module named 'numpy': Visual Studio Code
Trying to import numpy but VSCode gives me pylint(import-error)?
Problems: install NumPy on visual studio code with jupyter
Since you have mentioned in your comment that you can switch to a different IDE, please check Spyder
I have looked at these problems online but I don't seem to be able to find a good answer.
System details:
Mac OS BigSur 11.6 on a M1 MacBook Pro
Installed miniforge as discussed here
Installed VSCode for Mac
I have these two following (unrelated?) problems when using jupyter notebook:
PyLance does not resolve imports like numpy etc. I see that os or sys are recognized and resolved but pretty much nothing else is. The kernel used by the jupyter notebook is the correct one. Indeed I am able to run the code with no issues but I get all these unrecognized imports.
I am not able to run the jupyter notebook with %matplotlib notebook. I can run with %matplotlib inline, but then I am not able to see the widgets to zoom in etc. To be more precise, if I try to plot in a cell then after it I see the following:
either nothing or
the following <IPython.core.display.HTML object>
This is achieved by clicking on the symbol </> and changing the rendered from html to text.
I am wondering if there is some issue with my installation of python and jupyter on the M1 or it is a VSCode issue. Any suggestion on where to look into the problem(s)?
So I am trying to run some scripts just by opening the python file directly (not running through pycharm). However, when I import certain libraries (such as numpy or matplotlib) the terminal will close automatically, even if the program is waiting for user input. All of these scripts run without error in pycharm.
Here is an example of some imports that don't close the window automatically:
import tkinter as tk
import math as m
input('press enter to return')
Here is an example of some imports that do close the window automatically:
import numpy as np
import matplotlib as m
input('press enter to return')
What is going on here? I am relatively new to coding and so I think I might be missing something fundamental.
This might be because anaconda has not been installed to your system path, it's important to have python interpreter and IDE being set to PATH especially when you are working with libraries that are not pre-installed
Hope it cleared your doubts, if any errors, do let me know
Cheers
import numpy
is not working. This started because I couldn't get PyQt5 to work on my home computer. In the Spyder IDE, I can import modules and get everything working fine, but in VS Code, I can't import basic modules. I'm on Windows 10 with Python 3.7. I've Googled a lot and have tried these:
Uninstall Anaconda and VS Code, and reinstall both
In VS Code, press Ctrl+Shift+P, Select Interpreter, and select Python 3.7.1 64-bit ('base':conda), ~\Anaconda3\python.exe
I saw on another similar question that python3.dll may be missing from one of my Anaconda directories, but it is indeed there.
Add environment variable to PATH by going to System Properties > Advanced tab > Environment Variables... > under System Path, Edit, New > C:\Users\myname\Anaconda3\Scripts
Once I did #4 above, the new error message in VS Code when importing numpy is DLL load failed: The specified module could not be found. And in the terminal, I see: The term 'conda' is not recognized as the name of the cmdlet, ...
One thing I notice is in a Python prompt (not Anaconda) I type:
import sys
print(sys.version)
The output is 3.7.2, while in VS Code, the Select Interpreter (see above #2) says Python 3.7.1. Not sure if this is important.
Any help? Everything works on my work computer fine, but it's just my home computer that is being difficult.
What ended up working for me is downgrading my Python installation from 3.7.1 to 3.6.4 with:
conda install python=3.6.4
Hope this helps someone out there.
On another question for the same problem, there was a suggestion that worked for me.
Put this on the variable path.
C:\Users\<Your user name>\Anaconda3\Library\bin
credit to user1024.
I get "Undefined variable from import" error in Eclipse 3.7.2 PyDev 2.7.1 on Linux Mint Maya (Cinnamon) whenever I import a module from numpy. The problem only arises when importing numpy; other modules work just fine.
Info: numpy is compiled against the Intel MKL libraries. Python 2.7.3 [GCC 4.6.3]
example:
import numpy as np
a = np.array([1, 2])
Error message in PyDev editor:
"Undefined variable from import: array"
I get similar errors for other numpy submodules.
The code runs properly either within Eclipse or in a terminal. The problem is only present in the Eclipse-PyDev editor.
The LD_LIBRARY_PATH has to contain paths to the MKL libraries. Even if LD_LIBRARY_PATH is set properly, it has to be explicitly specifed in Eclipse under Window > Preferences > Interpreter - Python, under the "Environment" tab on the right hand side. Add a new variable called "LD_LIBRARY_PATH" and paste the content of $LD_LIBRARY_PATH.
Once it is done, errors will only disappear from your code if a line is added to the code which uses a numpy object so that imports are checked again.
I managed to fix it by updating the Phyton interpreter in Eclipse. Just click on Apply button after successfully installed Numpy module.
Are MKL libraries and numpy the same thing? #user1898039's answer didn't make sense to me (I'm not sure what path I should use for that property.
I found another way to fix this issue - I checked the python command line to see if numpy was installed there by calling:
>>> import from numpy *
It was not. So, despite the fact that numpy was showing up in PyDev under the "Forced Builtins" tab in the Python Interpreter properties, it wasn't available to python from the command line and I imagine this caused the issue inside PyDev.
So, I fixed the problem by going to the numpy site and installing the newest version for windows. Technically I went to some other site that had a AMD64 version of the installer for windows, buy you know, same same. After that I tried to get the PYTHONPATH variable to recalculate all the libraries (this may have been unnecessary), but errors were still showing in the file on all the calls to array(). I did an autocomplete on the numpy package to get the list of functions, selected array() from that list, and all of the sudden all the errors cleared and everything is fine now.
I was able to resolve this by adding the following path to PYTHONPATH (Pydev => Python Interpreters => select an Interpreter => Libraries):
/usr/local/anaconda/lib/python2.7/lib/lib-dynload
installed packages (among others):
conda==3.10.1
numpy==1.9.2
scipy==0.15.1
I occasionally see these errors for pandas objects, after re-starting Eclipse, even though I of course have 'import pandas as pd' at the top of my file.
I've discovered a simple workaround: I simply delete the import statement, save the file, paste it back in and re-save. The errors go away!
I'm on this version of Eclipse:
Eclipse for PHP Developers
Version: Mars.2 Release (4.5.2)
Build id: 20160218-0600