Skip to content
pyscripter edited this page Jun 6, 2023 · 34 revisions

paypal

Frequently Asked Questions


Which Python versions are supported?
How can I debug Django applications?
How do I use PyScripter with an unregistered version of Python (e.g. WinPython)?
When should I use the remote interpreter/debugger
How do I use the remote interpreter/debugger?
How do I use Matplotlib with PyScripter?
How do I use PyScripter with TortoiseHg installed?
How do I use PyScripter in Ubuntu?
How do I have autocompletion with PyQt4 or PyGtk?
Why am I getting UnicodeEncodeError/UnicodeDecodeError?
How do I use PyScripter with QGIS?

Which Python versions are supported?

PyScripter supports Python versions 2.4-2.7, 3.0-3.7.

Back to Top

How can I debug Django applications?

Here is how you can debug Django applications with PyScripter in six simple steps:

  1. In the File explorer locate the root directory of your Django application. You may want to right click on the directory name and select File Explorer, Explore here.
  2. Open the project files in PyScripter (e.g., models,py, views.py etc.) and set whatever breakpoints you want.
  3. Select Run, Command Line Parameters... and set the command line to "runserver --noreload". Also check the "Use Command line" checkbox.
  4. Make sure the remote engine is selected (Run, Python Engine, Remote).
  5. Open the manage.py file and press the debug button (or press F9).
  6. Start a web browser and test your application. PyScripter should now stop at whatever breakpoints you have set and you can use the various debugging facilities (call stack, variables, interpreter prompt etc.)

To stop debugging, right-click on the interpreter window and select "Reinitialize Interpreter", then go to the browser and reload the document.

Back to Top

How do I use PyScripter with an unregistered version of Python (e.g. WinPython)?

PyScripter 3.4 introduced an easy setup of multiple python versions including virtual environments (both venv and virtualenv are supported). You can also easily switch between python versions without exiting PyScripter. See this blog post for details.

The following guidance can be used with earlier versions of PyScriper. For instance, to use WinPython the following command file works. It assumes WinPython version is 2.7.9.amd64 and that it is located at C:\WinPython\python-2.7.9.amd64. Adjust this according to your WinPython version and installation directory.

SET PYTHONHOME=C:\WinPython\python-2.7.9.amd64
SET PYTHONPATH=C:\WinPython\python-2.7.9.amd64\Lib
SET HOME=C:\WinPython\settings
SET PATH=C:\WinPython\python-2.7.9.amd64\Lib\site-packages\PyQt4;C:\WinPython\python-2.7.9.amd64\;%PATH%
SET WINPYDIR=C:\WinPython\python-2.7.9.amd64
SET WINPYVER=2.7.9.3
PyScripter.exe --PYTHON27 --PYTHONDLLPATH "C:\WinPython\python-2.7.9.amd64" %1 %2 %3 %4 %5

Back to Top

When should I use the remote interpreter/debugger?

The remote interpreter/debugger is strongly recommended for all uses of PyScripter. It is more robust since it isolates the IDE from the Python engine that runs your scripts. It also allows you to start afresh by reinitializing the Python engine.

When you run GUI scripts such wxPython, Tkinter etc. it is necessary to use the remote Python engine and reinitialize the engine before each run. This last step is done automatically by default.

Back to Top

How do I use the remote interpreter/debugger?

See Remote Python Engines

Back to Top

How do I use Matplotlib with PyScripter?

To work with matplotlib within PyScripter you should use the Remote Python Engines.

You can also run matplotlib in interactive mode. Here is how:

  • Choose the right Python engine (Run, Python Engine menu option) for the backend of your choice e.g. Remote engine Tk for the "TkAgg" backend or Remote Engine wx for the "WX" and "WxAgg" backends.

  • Assuming that you have selected the Remote Engine wx, issue the following commands in the interpreter:

  >>> import matplotlib
  >>> matplotlib.interactive(True)
  >>> matplotlib.use("WXAgg")
  >>> from matplotlib.pylab import *
  >>> plot([1,2,3])
  >>> xlabel('time (s)') 
  • You can set the backend and interactive mode in the matplotlibrc file. If this is done, the following is sufficient for the above example:
  >>> from pylab import *
  >>> plot([1,2,3])
  >>> xlabel('time (s)')
  • Issue more pylab commands, or close the pylab window and call plot again for a new plot, etc.

Sample script by heylam

#Tested on: PyScripter 1.9.9.2, Matplotlib 0.91.2
 #Assumed setup:
 #In site-packages\matplotlib\mpl-data\matplotlibrc set backend to WXAgg.

def demoplot():
   '''This represents your work'''
   close('all') #closes figures
   t = c_[0:1:20j]
   s = cos(2*pi*t)
   for ampl in c_[0.1:1:10j]:
     plot(t, ampl*s, 'o-', lw=2)
   xlabel('time (s)')
   ylabel('voltage (mV)')
   title('demo', color='b')
   grid(True)
   draw() #update figure if already shown

#Select a demonstration:
 if 0: #Normal session
   #Starts non-interactive.
   #Figures have toolbar for zooming and panning.
   #Disadvantage: You can't re-run your script with PyScripter Remote
   # engine without first reinitializing the Remote interpreter.
   #Best use Remote(Wx) engine. This also allows interactive mode using
   # ion() and ioff(). For disadvantages: see the PyScripter help file.

#from numpy import *
   #from scipy import * #includes numpy
   from pylab import *  #includes scipy

demoplot()
   show() #Open the figure, let figure GUI take over.
     #This should be last line of script.
     #You can also type this at command line after the script exits.

if 0:
     ion() #turns interactive mode on  (needs Remote(Wx) engine!)
     ylabel('interactive modification')
     plot( rand(200), rand(200), 'go' )
     ioff() #turns interactive mode off

elif 0: #Same but use WX instead
   try:
     type(matplotlib)
   except NameError:
     import matplotlib
     matplotlib.use('WX')
     from matplotlib.pylab import *

demoplot()
   show() #Open the figure, let figure GUI take over.
     #This should be last line of script.
     #You can also type this at command line after the script exits.

elif 0: #Same but start as interactive session, needs Remote(Wx)engine.
   try:
     type(matplotlib)
   except NameError:
     import matplotlib
     matplotlib.interactive(True)
     from matplotlib.pylab import *

demoplot()
   show() #Open the figure, let figure GUI take over.
     #This should be last line of script.
     #You can also type this at command line after the script exits.

elif 0:#pdf output, allows use of Remote engine without re-initialization.
   #Disadvantage: no figure toolbar.
   #WARNING: close the file in acrobat reader before the next run.
   #(Maybe other pdf viewers don't block file overwrite)
   try:
     type(matplotlib)
   except NameError:
     import matplotlib
     matplotlib.use('PDF')
     from pylab import *

demoplot()
   filename='demo_plot'
   savefig(filename)

#view the file:
   import win32api
   win32api.ShellExecute(0, "open", filename+'.pdf', None, "", 1)

elif 1:#png output, allows use of Remote engine without re-initialization.
   #Disadvantage: no figure toolbar.
   #Tip: make Irfanview your standard viewer.
   from pylab import *

demoplot()
   filename='demo_plot'
   savefig(filename)

#view the file:
   import win32api
   win32api.ShellExecute(0, "open", filename+'.png', None, "", 1) 

Back to Top

How do I use PyScripter with TortoiseHg installed?

TortoiseHg is Windows Explorer extention for the Mercurial distributed revision control system. When installed it affects PyScripter in two ways.

  • It contains a custom python25.dll in its directory which is placed on the windows path
  • It loads various python library dlls in the running space of PyScripter through the PyScripter File Explorer

The above create problems that can be resolved as follows:

  • Solution 1

Use PyScripter with a python version different than 2.5 which comes with TortoiseHg. You can force PyScripter to use a specific version of Python using the -PYTHONxx start up flags e.g. PyScripter --PYTHON26

  • Solution 2

If you really need to use Python 2.5 then create a command file with the following

  regsvr32 /u "C:\Program Files\TortoiseHg\tortoisehg.dll" 
	PyScripter --PYTHON25 --PYTHONDLLPATH=c:\windows\system32
	regsvr32 "C:\Program Files\TortoiseHg\tortoisehg.dll" 

Then run PyScripter using this command file. Note that the PYTHONDLLPATH should point to the directory in which the originall python25.dll that came from the python installation program resides.

Update The incompatibility between PyScripter and the TortoiseHg Mercurial addon has finally been fixed with the release of TortoiseHg 0.8, which replaces the Python Windows shell extensions with C++ based ones.

Back to Top

How do I use PyScripter in Ubuntu?

This how-to is based on the XFCE 4.8 desktop running on top of Ubuntu 11.04. The easiest way to get this configuration is to install Xubuntu. Or from any Ubuntu distribution one can install the XFCE meta package from Synaptic and choose XFCE from the boot manager at login.

  • First, install Wine.

I installed version 1.3.15 via Synaptic.

  • Download the Python 2.7.2 Windows installer. (Other versions should work as well.) Accept the "open with Wine"

option and proceed with the installation as normal.

Double click on the exe and Wine will intercept it and run it automagically.

and proceed with the installation as normal. Applications menu>Wine>Programs>PyScripter> "your choice"

Both configurations seem to work flawlessly with the internal and remote python engines.

Back to Top

How do I have autocompletion with PyQt4 or PyGtk?

  • PyQt4

    • Go to Tools, Options, IDE Options, Special packages and add PyQt4 to the list

    • Tools, Edit Startup Scripts. Add to the end of pyscripter_init.py the following:

      from PyQt4 import QtCore, QtGui
      
    • Save and restart PyScripter, go to a new editor and type

      from PyQt4 import QtCore, QtGui
      QtGui.
      

      and voila. Code completion is available. See Support Group message for explanations.

  • PyGtk

Back to Top

Why am I getting UnicodeEncodeError/UnicodeDecodeError?

Most likely you are using scripts with file names containing non-ascii characters. Please see the blog post explaining the issue and providing advice for dealing with it.

Back to Top

How do I use PyScripter with QGIS?

Please see the blog post.

Back to Top