Visual Python working very slowly - python

I want to use visual for my project. I've used it many times before and everything was just fine, but I recently changed jobs so am using it on a machine that I've never worked on before
The problem is somewhat peculiar: when I run one of the example scripts from /visual/examples everything is just fine. However when I try to run a very simple script:
import visual
visual.sphere(pos=[0.,0.,0.],radius=1.,color=visual.color.red)
it takes a couple minutes to execute. This is completely unacceptable for the project I want to use it for.
I've tried running this sort of scripts from command line and IPython but the behaviour is the same: a visual window appears, Windows tags the window as "not responding" and then, after some painfully long time, the entire scene appears as expected.
This is clearly not a problem with what IDE I use to call visual and I'm seriously clueless about how to solve this. If that's of any importance I'm using a 64 bit Windows (also downloaded 64b visual) and a Python distribution that comes with Anaconda.
An interesting observation: The Python interpreter from which I run the script is not busy, i.e. I can execute other commands in it while the visual scene is not displaying correctly.
Any help or even ideas on what to do to try and resolve this issue would be very much appreciated.

Do you have either a visual.sleep(pause_time) or visual.rate(frequency) line somewhere in your visualization loop? VPython requires one of these two lines to update the animation window.

I would start from scratch with a base python distribution/implementation.
Try downloading first a stock 64-bit Windows Python-2.7.5 : http://python.org/ftp/python/2.7.5/python-2.7.5.amd64.msi
Then download VPython-Win-64 : http://sourceforge.net/projects/vpythonwx/files/6.05-release/VPython-Win-64-Py2.7-6.05.exe/download
If this doesn't work, then it might be an issue with something other than vpython or anaconda.
If you can get it to work properly, then you can isolate the problem to either Anaconda's python implementation or the VPython module itself.

Related

VS Code Python Syntax Highlighting Only Half Working

I've been using both VS Code and Sublime for a while now. I mostly do my python coding in Sublime and I have recently decided to try out VS Code. One issue though.
The syntax highlighting for python is not functioning in the manner I would expect. Here is a .py file opened in both VS Code and Sublime for comparison:
Sublime Text:
VS Code:
When comparing the VS Code syntax highlighting to that of Sublime, it appears to only function half correctly.
Tons of stuff that I would expect to receive some form of colored formatting such as function calls, function parameters etc all just appear as white text.
After looking at loads of VS Code python tutorials online, it would definitely seem something is wrong with my setup as everyone else seems to receive function calls/function paramters/etc syntax highlighting.
Troubleshooting progress so far:
I have the VS Code python extension installed.
I've tried uninstalling and reinstalling VS Code.
I've tried uninstalling and reinstalling Python extension.
I've tried installing the magicPython
extension.
Ensuring I have both python2 and python3 installed on my machine
Color theme is currently Dark+, however this behavior occurs with all
color themes.
Made sure the file ends in .py
I'm running on a Mac, if that's relevant.
Any help would be greatly appreciated. Thank you!
i think you just need to change your theme
check this one out https://github.com/sobolevn/dotfiles

.exe generated with pyinstaller crashes on other PCs - how to create .exe with TRULY no dependencies?

I have generated an .exe-file for a little PowerPoint Tool, that I've written using python 3.6, the PyQt5 framework and pyinstaller. The program runs without any errors on my own laptop and functions as expected.
Unfortunately, I can't get the .exe to run on a different computer. I've tried with 2 other computers now and get different errors on each of them.
PC 1:
Entry Point not found
The procedure entry point ucrtbase.terminate could not be
located in the dynamic link library api-ms-win-crt-runtime-l1-1-0.dll.
PC 2:
This application failed to start because it could not load the Qt platform plugin 'Windows'.
The thing, that bugs me is, that I had this last error (from PC2) during development on my dev computer, but fixed this problem for my own PC.
What I was trying to do is create an .exe-file that just runs on any PC. It's a simple PowerPoint Helper, which is supposed to be a quick tool to create new slides from a folder of images. That is why it's pretty important, that it can be seamlessly used. Ideally just opening the .exe and go, without the need to worry about individual missing pieces on every single computer, where it will be utilized.
BIG QUESTION: Is there anything I can do, to guarantee my .exe to include all the dependencies that are needed to run?
Things I've tried (aka I DID try to solve it myself.. for days):
read trough here: https://github.com/pyqt/python-qt5/issues/2
changed my .specas mentioned here: https://github.com/carlosperate/pyinstaller-test/blob/master/package/pyqt5_test.spec
read through all of this: https://stackoverflow.com/search?page=2&tab=Relevance&q=entry%20point%20not%20found
and this: https://stackoverflow.com/search?q=qt+platform+windows
and this: pyinstaller exe without any dependencies?
But nothing helps.... Most of the posts address problems when compiling the executable file, but this works just fine for me.
If using Python 3.5, PyInstaller 3.3.1 and PyQt 5.9.2 is an option for you, use fbs instead of PyInstaller to freeze your application. It is based on PyInstaller but solves edge cases like the one you are experiencing. There are instructions for setting up your app for use with fbs here.

PyInstaller app gets caught by SmartScreen

I made a program for people at work that simply takes csvs, converts them, and turns them into a csv that can be read by a different program and I have made the program in Python. Everyone here uses Windows so I originally used py2exe to make an exe and it worked fine for everyone.
Recently, I made some changes to the code to use the newest Python version which py2exe does not support so I used pyinstaller which worked great. However, when I passed it on to a few people at the office to test it, Windows SmartScreen caught it and the Anti-Virus program quarantined it for 3 hours. Obviously this is not ideal. What can I do to not make SmartScreen catch it? And why would py2exe not trigger the same warnings?
SmartScreen show this warning for executables that are not popular and unfortunately Microsoft does't give a certain number of downloads to SmartScreen stop triggering out.

python power shell issues

Edited to include a specific example
I am learning to use python and work in a windows 10 environment (although on 3 separate computers). I have gotten past the "add python to %PATH% issue" but continue to see odd outcomes when I call simple scripts from powershell compared to running them from the python terminal. For example, I often see that lines of code are duplicated, even simple print statements. A second repeating issue is that some (but not all) modules work fine in the python terminal but can't be found when running a script from powershell, despite using pip install within powershell to install it in the first place.
Rather then seeking help on a specific issue, I'm hoping for some guidance into how powershell and python interact that might help me understand or identify some commonalities in these issues I keep experiencing that are common from within powershell. If thats as simple as redirecting me towards another source even that'd be apprecaited. But my search results always turn up the common issue of powershell not knowing what python is, and needing to add python to the PATH. But as indicated, I have already gotten past this and can get %50 of my python to work from powershell. There must be something else perhaps obvious to others that I'm missing that can help me understand why some things aren't working while others are.
Thanks for taking the time to consider my problem and any advice is greatly apprecaited.
Here is an example from some code I am trying to get working, but in troubleshooting I have taken out a lot of code and am now only running what is shown that defines a dataframe and a print statement. Everything works line by line in python, but when I call the script from powershell, the print statement executes twice.
#!/usr/bin/python3
import pandas as pd
joedata = {'fpr': [0.2,0.4,0.8], 'tpr':[0.9,0.5,0.1]}
joeframe = pd.DataFrame(data=joedata)
print(joeframe)
Concerning modules, you probably have multiple versions of Python installed on your system. Calling pip in the Powershell doesn't mean that it will install for the Python installation which is called by default when you execute Python in the Powershell. So you should try to figure out on which version pip is installing packages and which version is actually used when executing a script.
EDIT: I tested the example that you gave in Powershell and I don't have the problem, it's working fine.
Moreover, for me, without doing any special configuration, in Powershell the commands pip and python refer to the same version of Python. If by default everything is ok, you should consider uninstalling Python and just running the installer again and let it manage the PATH, etc.

Python: Two Windows Opening

ok so for the past two weeks or so, ive been learning python as it is extremely simple to comprehend and a very handy method of creating a GUI for a program. However i have three problems.
First, when i open my .py file a command window opens , and then my program opens on top of that. Is there a way to just open the program? (and not the command window)
Second, ive been eagerly searching for a simple method of compiling (or "interpreting")
my .py filesinto .exe files. ive come across a few people saying that the program called py2exe is the best method, however i cant get it to work... Are there any easier methods for compiling python source codes into executable files?
Third, can anyone refer me to a site with a list of modules for python, along with their descriptions and.or examples? this would greatly help me as i tried using the built in help commands in the python command line, but i find that too generic, like it gives the syntax but no examples of what applications each command/module has.
P.S: Just wondering, is there a site that offers example programs (and their source codes) that were made with python that i could take a look at to better understand this language?
(examples: Python Games, Python GUI applications, Python Questionaires, Any Python Programs/applications that demonstrate the language's usefulness)
INFORMATION:
OS: WINDOWS 7: Ultimate Edition
Python Version: 2.6
Thanks in Advance!
To keep the command window from opening, you can save it as a .pyw file, as opposed to the usual .py. As for converting to exe, py2exe works best for me, I know there are several others, but not as fully developed as py2exe is. Python.org should contain a list of most modules. The same results could easily be procured by googling python modules.
EDIT:
Also, as for the gui, I have found that I personally like pyqt and tkinter best.
Use pythonw.exe instead of python.exe to run your program.
I use cx_freeze; docs on their website.
PyPI

Categories