Menu

FAQ

Featured (5)
Anonymous

Frequently Asked Questions

  • Frequently Asked Questions
    • Which Python versions are supported?
    • How can I debug Django applications?
    • How do I use PyScripter with Portable (Movable) Python?
    • How do I use PyScripter with an unregistered version of Python?
    • 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 ?

Which Python versions are supported?

PyScripter supports Python versions 2.3, 2.4, 2.5, 2.6, 3.0 and 3.1. You should consider support for version 2.3 as deprecated and likely to be dropped soon.

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 Portable (Movable) Python?

You can very easily setup PyScripter so that it can work with unregistered versions of Python such as for example Portable Python and Movable Python which are typically residing in a USB stick or a portable hard disk.

Steps:

a) Download the zip-only distribution from the PyScripter downloads page and extract it to a directory of your choice in the portable drive.

b) From an existing PyScripter installation copy PyScripter.ini (this file is typically located in the %APPDATA%\PyScripter directory) to the same directory as the PyScripter.exe file..

c) In the same directory create a batch or command file that will set the PYTHONHOME environment variable and start PyScripter with appropriate command-line options e.g.

SET PYTHONHOME=E:\PortablePython 
PyScripter --PYTHON25 --PYTHONDLLPATH "E:\PortablePython" %1 %2 %3 %4 %5

d) Start PyScripter using the created batch file.

Back to Top

How do I use PyScripter with an unregistered version of Python?

See answer above

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.pythe following:

from PyQt4 import QtCore, QtGui

* Save and restart [PyScripter](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.

Back to Top

Why am I getting UnicodeEncodeError/UnicodeDecodeError?

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

Back to Top


Related

Home: Home
Wiki: PyScripter
Wiki: RemoteEngines
Wiki: Sidebar

Discussion

  • Anonymous

    Anonymous - 2012-03-18

    Originally posted by: map...@gmail.com

    for the "portable python" batch file example above, use %* instead of %1 %2 ... %5 to capture all command line parameters instead of just the first five. Also on WinXP and above, %~dp0 can be used to determine the path of the currently running batchfile (so the drive letter doesn't need to be hard coded).

    Example, pyscripter25.bat at root of portable drive:

    SET PYTHONHOME=%~dp0\PortablePython 
    PyScripter --PYTHON25 --PYTHONDLLPATH "%~dp0\PortablePython" %*
    
     

    Last edit: Anonymous 2019-01-24
  • Anonymous

    Anonymous - 2012-09-26

    Originally posted by: lars.ru...@gmail.com

    Following the discussion in https://groups.google.com/d/topic/pyscripter/1xwy0yltTrA/discussion As i guess no one will ever put this into the FAQ, i'm posting this here, in the hope it will get picked up by search engines and may be helpfull to others.

    How do I use PyScripter with virtualenv? There's a problem if you use PyScripter with the remote python engine in a virutalenv environment. On Microsoft Windows, if ENV is your virtual python environment (created with 'python virtualenv.py ENV'), then after switching to this environment, the python.exe executable is located in C:\Python27\ENV\Scripts. (Or whatever your Python version and installation directory is) However, PyScripter expects it to be in C:\Python27\ENV. You can use this workaround: Create a symbolic link from C:\Python27\ENV\python.exe to C:\Python27\ENV\Scripts\python.exe . On Windows Vista or 7, you may use the mklink command to do this:

    mklink C:\Python27\ENV\python.exe C:\Python27\ENV\Scripts\python.exe

    (you'll need administrator privilleges to do this). Start PyScripter via a batch file with the following commands:

    CALL C:\Python27\ENV\Scripts\activate.bat
    SET PYTHONHOME=%VIRTUAL_ENV%
    START project.psproj
    

    The first line activates the virtual environment ENV. The second line sets the PYTHONHOME environment variable to the one defined by virtualenv, i.e. 'C:\Python27\ENV'. This is that Python finds all libraries specific to that environment. The last line starts PyScripter via a project file. You might as well call PyScripter.exe directly. Versions tested: Python 2.7.3 PyScripter 2.5.3.0 x86 virtualenv 1.8.2 on Windows 7 (32 bit)

     

    Last edit: Anonymous 2019-01-24
  • Anonymous

    Anonymous - 2013-03-13

    Originally posted by: alessand...@gmail.com

    when i import liblas module i have this message

    import liblas Traceback (most recent call last):

    File "<interactive input>", line 1, in <module> File "C:\Python27\lib\site-packages\liblas__init__.py", line 2, in <module>

    from core import get_version

    File "C:\Python27\lib\site-packages\liblas\core.py", line 138, in <module>

    las = ctypes.CDLL(os.path.join(local_dlls, lib_name))

    File "C:\Python27\Lib\ctypes__init.py", line 365, in init__

    self._handle = _dlopen(self._name, mode) _

    WindowsError?: 193? %1 is not a valid Win32 application

     

    Last edit: Anonymous 2019-01-24
  • Anonymous

    Anonymous - 2013-05-04

    Originally posted by: garyrh...@gmail.com

    Are there any plans to port PyScripter to Linux?

     

    Last edit: Anonymous 2019-01-24
  • Averell

    Averell - 2018-02-09

    It would be really intersting to use PyScripter as an IDE pour OpenOffice / LibreOffice, which slill lacks an IDE for python programming. It is possible to define the LibreOffice python as an external engine. I have a script (8000 lines) which is properly run by PyScripter with the external engine properly configured, and then Run / External Run (Alt + F9). But this does not allow debugging. So I tried to use the FAQ option above : How do I use PyScripter with an unregistered version of Python?.

    PyScripter starts well with :

    SET PYTHONHOME=c:\Prog2\LibreOffice 5\program\python-core-3.3.0\
    PyScripter --PYTHON33 --PYTHONDLLPATH "c:\Prog2\LibreOffice 5\program\" %*
    

    Be careful with the quotes.

    Tools / Python Path shows :
    c:\Prog2\LibreOffice 5\program\python-core-3.3.0\DLLs
    c:\Prog2\LibreOffice 5\program\python-core-3.3.0\lib
    c:\Prog2\LibreOffice 5\program\python-core-3.3.0
    c:\Prog2\LibreOffice 5\program\python33.zip
    c:\Prog2\LibreOffice 5\program\python-core-3.3.0\lib\site-packages

    "import uno" raises the error : "No module named 'uno' ".
    If I add a line in the python paths :
    c:\Prog2\LibreOffice 5\program
    then, "import uno" works, but "from com.sun.star. ... import ...." fails :
    "ImportError: No module named 'com' (or 'com.sun.star.script.provider.XScriptContext' is unknown)"

    I will update the post if I find a solution

     

    Last edit: Averell 2018-02-09
  • Brian Hultin

    Brian Hultin - 2022-05-29

    Hi from the future, did you ever figure this out? I am having the same issue with IntelliJ.

     
  • Averell

    Averell - 2022-05-29

    Unfortunately I didn't find a solution. It is a pity that LibreOffice which supports python scripts for more than a decade has never made any effort to give us a proper IDE.

     
  • Brian Hultin

    Brian Hultin - 2022-06-07

    Hello,

    I was able to get things working with IntelliJ with the help of a tool called IDE_Utils, found here: https://gitlab.com/LibreOfficiant/ide_utils/-/tree/master

    Add it to your LibreOffice/program/ directory.

    Download the official python that matches your LibreOffice, mine was 3.8.10. From Intellij create a new Python project and new virtual environment using it as the SDK. Close the project. Then create a new Python project, choose Add Python SDK... -> Virtual Environment -> Existing environment -> C:\Program Files\LibreOffice\program\python.exe as referenced here: https://wiki.documentfoundation.org/Macros/Python_Basics under IDE Project Setup -> Pycharm (also made by JetBrains). It seems this custom python knows all about the Uno files.

    Finally you may need to update line 154 of IDE_Utils to point to your LibreOffice install.

    Open an odt file (LibreOffice Writer document) and run the sample macros from IDE_Utils. I was able to get Hello World to print in the document.

    Perhaps the first virtual environment is not needed but this is what worked for me.

    Order of images: Exisiting_environment, Add_python_sdk, Project_name_and_paths

     

    Last edit: Brian Hultin 2022-06-07

Log in to post a comment.