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
Related
I'd like to write Cython in vscode using the built-in jupyter notebook and Cython extension. I can actually do it and it will compile just fine, but vscode thinks it's python code and will complain about all kinds of syntax and linting errors. I know I could write in pure python mode, but I'm also trying to learn Cython simultaneously, so that's not very helpful.
I tried installing Cython language extensions, but none of them appeared in vscode when I tried to switch language of cell.
Is this possible? How could I do this?
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)?
I just installed VSCode 1.59.0 along with the Julia, Jupyter, and Python extensions. I am able to create Jupyter notebooks using either Julia or Python. When I create a notebook using Python, I see the variables I create listed in the Jupyter: Variables tab. When I create a notebook using Julia, however, I do not see the variables I create listed anywhere.
At the present moment, while Julia is generally supported in the VS Code Extension, this specific feature is not supported. I have an issue on the Microsoft side and Julia VS Code side open here: https://github.com/microsoft/vscode-jupyter/issues/7224 to hopefully kick start this process.
The Julia VS Code extension does already support this feature outside of Notebooks (when running a ".jl" file) so this should seemingly not be too difficult of a task to port it over to the Jupyter extension, but I am unfamiliar with the level of technical rigor this would require.
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