Recently started using the code editor Atom for my Python code. I've been able to get pretty much everything I need to work, except VPython. I've been told that VPython is supported/compatible with Atom, yet it doesn't work.
The main issue is that I'm unable to import the 'visual' module. I've even tried suggested alternatives such as importing 'VPython' or 'vis', and even uninstalled/reinstalled VPython several times in different ways.
Any advice would be highly appreciated.
Check out the Hydrogen package in Atom:
https://atom.io/packages/Hydrogen
Run code and get results inline using Jupyter kernels like IPython, IJulia, and iTorch. It's one of the coolest packages in Atom as it supports inline plot visualizations if that's what you're looking for.
I hope this helps.
The visual module is part of "classic vpython" which only runs on python 2.7 . If you are using python 3.5.3 or higher then you will need the new VPython 7.x package which is probably what you installed if you followed the instructions at vpython.org . Try running this two lines vpython code.
from vpython import *
box()
If you run these two lines of code you should see a 3D box appear in a webgl canvas in your webbrowser. To write a vpython program use the new syntax and not the old "classic vpython" syntax.
http://www.glowscript.org/docs/VPythonDocs/index.html
Related
I'm now trying to run qiskit visualization functions(e.g. .draw() methods) in vscode.
I use latest version of Python, 3.11.1, and followed Getting Started Qiskit in here.
Also I installed qiskit extension in vscode.
However, when I run a qiskit code, the visualization functions don't work, even though code is compiled successfully.
I checked visualizing modules(mathplotlib, etc.) were installed.
I tried to re-install Python and vscode, including downgrading Python to 3.8. And it didn't work.
Additionally, qiskit-chemistry and qiskit-aqua installation warnings are pop-upped, but installation doesn't work.
I really don't know it is related on this problem, but I think maybe it's not since qiskit-aqua is deprecated.
The following screenshot is result of the qiskit test code.
result of running
draw() and plot_histogram() doesn't work as you can see.
How can I fix this problem?
These functions are meant to be used in Python Notebooks - they won't show up in normal .py files. Try using VSCode's Jupyter Notebook (.ipynb files) feature instead.
I am having a bit of trouble getting my plotly imports to work. I am a new Python programmer.
I followed the following instructions to a 'T':
https://plot.ly/python/getting-started/
When I copied the demo code into pycharm, I got errors on the imports. So I found a guy who had the same question as me here:
Import error : No module named plotly.plotly
Following prompts in the comments, I used "pip show plotly" in my command line, and copied and pasted the path, and reformatted the import like so (again as prompted by comments and the accepted answer:
import sys
sys.path.insert(0, 'c:\users\wesle\appdata\local\programs\python\python36-32\lib\site-packages')
import plotly.plotly as py
Still getting the same red squigglies...
Is plotly the right library to be using for a beginner? I will be using it to plot the results of numerical methods like calculating function values using taylor series and linear algebra stuff. I don't need super fancy, just whatever is easiest to code. By the way, really digging Python coming from Java.
So, I'm not a command line expert and decided to look within my IDE for a tool to set up plotly, as I was not having success with the "pip" stuff. I am using PyCharm, and the following simple steps took care of my problems in less than 30 seconds.
Settings
Click Project: "MyProjectHere" in left hand nav menu
Select Project Interpreter from the above drop down
Find the green 'plus' sign near the upper right edge of the window
that comes up.
Type Plotly in the search bar
Click install.
Maybe one day I won't be a dumb monkey who doesn't know how to use a command line like all the cool kids, but for now this worked for me.
If you are using Anaconda Python for notebook, you have to manually install plotly in anaconda:
Open Anaconda navigator
Go to Environments
Change installed to not installed
Search packages field and type plotly as uninstalled
Select it and click apply
After it gets installed you'll be able to import the package in notebook.
On my working PC (Windows7, no internet connection) there are two Pythons: one is the main (C:\Python36-32) with IDLE. Another - freshly installed Anaconda (C:\ProgramData\Anaconda3) - just for scipy and matplotlib (IT guy thought it is the best option).
So, matplotlib works only if I run my scripts from cmd. But it is not comfortable. I prefer IDLE or any other modern environment.
But if I try use matplotlib in IDLE - I got an "No module named 'matplotlib'". I tried to edit sys.path and run:
sys.path.append("C:\\ProgramData\\Anaconda3\\Lib\\site-packages").
It helps a little bit - I got new error "No module named 'matplotlib._path'". So, it looks like IDLE knows what is matplotlib now, but doesn't know it's functions.
Is there any way to connect IDLE with Anaconda's libraries? Maybe to append paths recursively?
It's probably not a good idea to mix the python distributions through the system path.
Python should ship with IDLE. So you can use the IDLE from the Anaconda distribution,
C:\ProgramData\Anaconda3>python.exe Lib\idlelib\idle.py
Also note that Anaconda should also provide Spyder. This might be a nicer IDE.
Being a complete begginer in python, I decided to install the python interpreter 3.4.4, and also PyDev plugin for eclipse IDE. I am also using windows 10.
I have encountered a problem regarding certain imports, namely : from PIL import Image, ImageTk, which is apparently an unresolved import.
I have looked at certain questions which were similar to my situation, but most of them gave a solution like installing packaged from the linux apt-get. Here are some topics I visited :
Uninstalling and reinstalling Pillow and pip,
Installing pillow-imaging-tk on Ubuntu,
This topic which left me very confused,
This one seemed helpful, but is on Unix OS again
So please, could someone explain to me why I am seeing this error, and how could I correct it if I absolutely want to use Eclipse, Pydev, windows 10 and Python 3.
Found the solution, here's what I did:
Set the PYTHONPATH like it is shown in this article, make sure python.exe is accessible via cmd,
Via cmd, type pip install pillow. Alternatively, you can enter the same command from Windows+R,
(Not sure if relevant step) Via eclipse, Windows->Preferences->PyDev->PythonInterpreterremove your interpreter to re-add it,
Restart eclipse.
For Python import problems in PyDev, the project web site has a page on interpreter configuration that is a good place to start. I recently had a similar problem that I solved by adding a module to the forced builtins tab.
I've been using Visual Studio Community for a few months now, but the sluggishness and project-based interface is not to my liking and having seen that Visual Studio Code has a python extension, I decided to try Code again.
There are two problems with Code, that if possible to solve I'd promote it to my main editor.
First is intellisense. I have downloaded the python extension for Code, which promises intellisense. However, outside of the core python packages (like "math") intellisense is not working. I've tried to set up the extra environment variable as described in the link, but that didn't work either.
After this I re-crated an anaconda environment, just in case. Each anaconda environment basically operates as a separate python install and has the modules like "scipy" etc under Lib/site-packages to properly be able to reference them.
As you might guess, intellisense for VS Code still isn't working. Maybe there's a way to refresh its database like for VS Community but I couldn't find it.
My second issue is lack of auto-indentation for python, which wasn't the case when I first installed Code some 6 months ago. The issue was present 2-3 months ago, I hoped it was fixed by now but apparently not. There's nothing new written about it on the Internets either.
How do I get VS Code to work well for me with python?
I have installed python 3.6.5 and Django 2.0.4 on windows 10 OS.
In vs code open command palette (Ctrl+Shift+p).
There select Python:Select Interpreter
Close your vs code and then try. If it still does not work. Try again by changing to:-
Python:Build Workspace symbols and re-open the vs code. That's all i did and got intelligence enabled.
Old question that worth another working answer:
In settings.json, set the value of python.jediEnabled to false (see some more details here).
P.S. You can also try and move back to Jedi (just remove python.jediEnabled or set it to true), and in my case, Intellisense keeps working, though much slower.
This is how I got Python intellisense to start working in VS Code:
open up the Terminal (View menu => Terminal)
type conda init powershell
restart VS Code
After that, Python intellisense started working correctly for me.
On your VS code use the command ctr + shift + P then search for Python: Select Lint and choose your preferred linting tool. This worked for me.
Bro, instead of
import matplotlib.pyplot as plt
Try:
from matplotlib import pyplot as plt
I've tried it in VSCode and it works for the second statement but not the first statement.
This is how I got it to work:
Open command palette (Ctrl + Shift + P).
Type "Python: Build Workspace Symbols" and hit Enter.
Done.