PyScripter and virtualenv: Problem running remote Python engine

1,388 views
Skip to first unread message

Lars Ruoff

unread,
Sep 7, 2012, 5:28:49 PM9/7/12
to pyscr...@googlegroups.com
Hi,
I'd like to use PyScripter on a Windows 7 installation with virtualenv.
I tried to follow the hint given in this thread:

I set a batch file to start my Pyscripter project file like this:
CALL C:\Python27\my4x\Scripts\activate.bat
SET PYTHONHOME=%VIRTUAL_ENV%
START my4x.psproj

But once PyScripter is started, when Running a script, it complains:
"Error in creating the remote interpreter: system Error. code: 2. The system cannot find the specified file"
It then falls back to the Internal Pythone engine which runs the script fine.
but I'd like to use teh remote engine, as recommended.
so what is wrong?

Going over "External Run" with Application=$[PythonExe-Short] gives the same kind of error.
(System Error.  Code: 2. The system cannot find the file specified.)
Here, the output says:
Command line: C:\Python27\my4x\python.exe D:\Projects\my4x\test\TEST-P~3.PY
Working directory: D:\Projects\my4x\test
Timeout: 0 ms

Which probably hints towards the cause:
The virutalenv Python executable is not
C:\Python27\my4x\python.exe
but rather
C:\Python27\my4x\Scripts\python.exe

How do i tell this to PyScripter?
Note that i prefer not to put any absolute, machine dependent paths in my project file, since it is being used by different porgrammers on different machines.
The question is basically how does PyScripter construct the path for the remote Python executable? And how can this be made to play nicely with virtualenv?

regards,
Lars R.

Kiriakos Vlahos

unread,
Sep 8, 2012, 6:49:45 PM9/8/12
to pyscr...@googlegroups.com
PyScripter expects the python.exe file to be located in the root python directory as in all standard python distributions.  The solution therefore might be to copy python.exe to the root python directory.


--
You received this message because you are subscribed to the Google Groups "PyScripter" group.
To view this discussion on the web visit https://groups.google.com/d/msg/pyscripter/-/vCxJqHFhYeAJ.
To post to this group, send email to pyscr...@googlegroups.com.
To unsubscribe from this group, send email to pyscripter+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pyscripter?hl=en.

Lars Ruoff

unread,
Sep 9, 2012, 6:16:15 AM9/9/12
to pyscr...@googlegroups.com

> PyScripter expects the python.exe file to be located in the root python directory 
And that is? $PYTHONHOME ?
Apparently not, as PYTHONHOME is not defined on my system by default and PyScripter works just well.
So how does PyScripter determine the root python directory? At installation time?

Lars Ruoff

unread,
Sep 9, 2012, 9:23:48 AM9/9/12
to pyscr...@googlegroups.com
Ok, now i have added a symbolic link from C:\Python27\my4x\python.exe to C:\Python27\my4x\Scripts\python.exe
Together with the batch options in the top post, this seems to work for me now.
I.e. i am able to run the remote python engine within PyScripter and it uses the my4x virtualenv.
It seems a bit fiddly, but the solution has the benefit of not having any other installation-dependent settings than in the batch file and the symbolic link.
Maybe something that should be added to the FAQ?

PyScripter

unread,
Sep 9, 2012, 8:47:37 PM9/9/12
to pyscr...@googlegroups.com
It gets the root python directory using sys.prefix.

PyScripter

unread,
Sep 9, 2012, 8:48:28 PM9/9/12
to pyscr...@googlegroups.com
Sure.  Could you please provide a detailed account including how to create  symbolic links?

Lars Ruoff

unread,
Sep 10, 2012, 3:14:58 PM9/10/12
to pyscr...@googlegroups.com
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)

Polon10y11 Chano

unread,
Mar 13, 2019, 3:48:35 PM3/13/19
to PyScripter
Ya sé que éste es un tópico antiguo, pero me he topado con muchos sitios donde no se da respuesta a la pregunta que se plantea, ni siquiera en el wiki de PyScripter.
Para ejecutar el ambiente virtual de un proyecto Python-Django hice lo siguiente:

1.- En el menú Run >> Python versions >> Setup Python versions
2.- Agregar una nueva versión no registrada
3.- Buscar el archivo Python.exe que se copia cuando se crea el ambiente virtual
4.- Hacer doble clic para inicializar el ambiente virtual
5.- Abrir el archivo manage.py del proyecto y ejecutarlo (Crtl+F9)
6.- Verificar en el intérprete de Python los mensajes de ejecucion
Reply all
Reply to author
Forward
0 new messages