Hi Guys,
I've been using the following IDE,
"Pythonwin - Python IDE and GUI Framework for Windows.
Copyright 1994-2001 Mark Hammond "
With respect to my work, I had created my own modules (.py files) in
drives and folders other than the python root. I know that if I need to
import these modules, I need to specify the path of the directory where
I've put my modules. I've tried the "Edit Python Path" sub menu in the
menu "Tools" of PythonWin, but I could not add a new path i.e.-
D:\xxxx\xxxx\xxxx\ATS.
Could any one please let me know how could I add a new path to access
my own modules.
Thanks in advance,
Mohan Swaminathan. 17 5242
mohan wrote:
I had created my own modules (.py files) in
drives and folders other than the python root.
Probably easiest if you keep them all in one place. Then add that
"place" to your path by going into Control
Panel|System|Advanced|Environment Variables and adding the path to the
path variable.
Hope that helps.
rd
BartlebyScrivener wrote:
mohan wrote:
I had created my own modules (.py files) in
drives and folders other than the python root.
Probably easiest if you keep them all in one place. Then add that
"place" to your path by going into Control
Panel|System|Advanced|Environment Variables and adding the path to the
path variable.
Hope that helps.
rd
Thanks rd,
I tried your advice, by adding a new path to the "System Variable"
section. It still does not work. I don't understand how could PythonWin
interpreter would look for new folders when we have not yet updated the
path in the interpreter. I'm sorry I might be mising something here as
i'm not too familiar with these things.
Any further ideas??
Regards,
Mohan.
mohan ha escrito:
I had created my own modules (.py files) in
drives and folders other than the python root.
I tried your advice, by adding a new path to the "System Variable"
section. It still does not work. I don't understand how could PythonWin
There was an error in a previous post, you should create a variable
called PYTHONPATH, not change the system PATH.
Or, group your modules into packages and put them below
lib\site-packages.
--
Gabriel Genellina
Gabriel Genellina wrote:
>
There was an error in a previous post, you should create a variable
called PYTHONPATH, not change the system PATH.
Or, group your modules into packages and put them below
lib\site-packages.
Perhaps your way works also, but I have no PythonPath defined in system
variables on Windows XP.
I keep my Python scripts and modules in d:\Python. I added d:\Python to
the Path variable and I can call and import the scripts and modules
from anywhere I please.
I'm pretty sure that the ActiveState distribution of Python adds its
paths to the Path variable also.
rd
BartlebyScrivener wrote:
Perhaps your way works also, but I have no PythonPath defined in system
variables on Windows XP.
I keep my Python scripts and modules in d:\Python. I added d:\Python to
the Path variable and I can call and import the scripts and modules
from anywhere I please.
Python does *not* use the Path when searching for modules; sys.path is
initialized based on the contents of PYTHONPATH, the location of the
Python executable (or PYTHONHOME), some heuristics, and certain registry
entries. there used to be a page about this on python.org, but it seems
to have disappeared; here's the SVN copy: https://svn.python.org/www/trunk/pyd...ws/registry.ht
</F>
Fredrik Lundh wrote:
Python does *not* use the Path when searching for modules; sys.path is
initialized based on the contents of PYTHONPATH, the location of the
Python executable (or PYTHONHOME), some heuristics, and certain registry
entries.
Now I'm stumped. Unless it's heuristics. The registry entry for
PythonPath does NOT reference the location of my Python scripts
(d:/Python). And Python is installed in the usual place on C:\Python24.
The only place that I can see where I've told it the location of my
scripts is in the Path variable.
I have no doubt that you're correct. Just confused as usual.
rd
At Wednesday 13/12/2006 10:10, BartlebyScrivener wrote:
Python does *not* use the Path when searching for modules; sys.path is
initialized based on the contents of PYTHONPATH, the location of the
Python executable (or PYTHONHOME), some heuristics, and certain registry
entries.
Now I'm stumped. Unless it's heuristics. The registry entry for PythonPath does NOT reference the location of my Python scripts (d:/Python). And Python is installed in the usual place on C:\Python24. The only place that I can see where I've told it the location of my scripts is in the Path variable.
I have no doubt that you're correct. Just confused as usual.
import sys
print sys.path
and see what's there.
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ˇgratis!
ˇAbrí tu cuenta ya! - http://correo.yahoo.com.ar
Gabriel Genellina wrote:
>
import sys
print sys.path
and see what's there.
Yup. Did that before. That's what I mean. The d:\\python is there and
it doesn't come from the PythonPath in my windows registry. Maybe it
scans for any directory with python in the name?
['', 'C:\\WINDOWS\\system32\\python24.zip', 'd:\\python',
'C:\\Python24\\DLLs', 'C:\\Python24\\lib',
'C:\\Python24\\lib\\plat-win', 'C:\\Python24\\lib\\lib-tk',
'C:\\Python24\\Lib\\site-packages\\pythonwin', 'C:\\Python24',
'C:\\Python24\\lib\\site-packages',
'C:\\Python24\\lib\\site-packages\\win32',
'C:\\Python24\\lib\\site-packages\\win32\\lib',
'C:\\Python24\\lib\\site-packages\\wx-2.7.1-msw-ansi']
rd
BartlebyScrivener wrote:
Yup. Did that before. That's what I mean. The d:\\python is there and
it doesn't come from the PythonPath in my windows registry.
what do you get if you do:
python -S
....
>>import sys sys.path
and then
>>import site sys.path
?
</F>
BartlebyScrivener wrote:
Yup. Did that before. That's what I mean. The d:\\python is there and
it doesn't come from the PythonPath in my windows registry. Maybe it
scans for any directory with python in the name?
Do you have any *.pth files in the C:\Python24 directory?
....
jay
Fredrik Lundh wrote:
what do you get if you do:
python -S
...
>>import sys sys.path
['', 'C:\\WINDOWS\\system32\\python24.zip', 'd:\\python',
'C:\\Python24\\DLLs', 'C:\\Python24\\lib',
'C:\\Python24\\lib\\plat-win', 'C:\\Python24\\lib\\lib-tk', 'C:\
\Python24']
and then
>>import site sys.path
['d:\\python', 'C:\\WINDOWS\\system32\\python24.zip',
'C:\\Python24\\DLLs', 'C:\\Python24\\lib',
'C:\\Python24\\lib\\plat-win', 'C:\\Python24\\lib\\lib-tk', 'C:\\Pyt
hon24', 'C:\\Python24\\lib\\site-packages',
'C:\\Python24\\lib\\site-packages\\win32',
'C:\\Python24\\lib\\site-packages\\win32\\lib',
'C:\\Python24\\lib\\site-packa
ges\\Pythonwin', 'C:\\Python24\\lib\\site-packages\\wx-2.7.1-msw-ansi']
rd
jay graves wrote:
>
Do you have any *.pth files in the C:\Python24 directory?
No.
BartlebyScrivener wrote:
>what do you get if you do:
>>python -S
...
>>>import sys sys.path
['', 'C:\\WINDOWS\\system32\\python24.zip', 'd:\\python',
'C:\\Python24\\DLLs', 'C:\\Python24\\lib',
'C:\\Python24\\lib\\plat-win', 'C:\\Python24\\lib\\lib-tk', 'C:\
\Python24']
since it appears *after* the ZIP archive, but before the standard path,
it should be either a registry setting or a custom-built interpreter
(is this an ActiveState build?). or maybe you could get this effect if
you have a copy of "python.exe" in d:\python, but I'm pretty sure that
the directory should end up at the *end* of the path in that case.
have you searched the *entire* registry for the "PythonCore" key?
(python looks under HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER)
what's sys.prefix and sys.exec_prefix set to on your machine, btw?
</F>
Fredrik Lundh wrote:
is this an ActiveState build?
Yes, I think I mentioned it further up the thread.
what's sys.prefix and sys.exec_prefix set to on your machine, btw?
'C:\\Python24'
No big deal. I always just assumed that it found my scripts via the
path variable. As long as it finds them. I'm happy.
But you got me thinking. I just did the commands you suggested on my
laptop, after installing python.org 2.5. With 'd:\python' in the path
environmental variable there also, it does NOT appear when I do plain
old:
>>>sys.path
but does appear when I import site first.
rd
Fredrik Lundh wrote:
>
have you searched the *entire* registry for the "PythonCore" key?
(python looks under HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER)
I found it in the Scripts key! I was searching on PythonPath before.
Sorry. Thank you for the enlightenment.
rd
BartlebyScrivener wrote:
Gabriel Genellina wrote:
import sys
print sys.path
and see what's there.
Yup. Did that before. That's what I mean. The d:\\python is there and
it doesn't come from the PythonPath in my windows registry. Maybe it
scans for any directory with python in the name?
['', 'C:\\WINDOWS\\system32\\python24.zip', 'd:\\python',
'C:\\Python24\\DLLs', 'C:\\Python24\\lib',
'C:\\Python24\\lib\\plat-win', 'C:\\Python24\\lib\\lib-tk',
'C:\\Python24\\Lib\\site-packages\\pythonwin', 'C:\\Python24',
'C:\\Python24\\lib\\site-packages',
'C:\\Python24\\lib\\site-packages\\win32',
'C:\\Python24\\lib\\site-packages\\win32\\lib',
'C:\\Python24\\lib\\site-packages\\wx-2.7.1-msw-ansi']
rd
Hi rd,
To revert back to my question, I wanted to add a new path to my
PythonWin IDE to access modules which are in folders other than normal
python paths. Here, I need to put my modules in different folders
since it is a request of the user. I tried to create a new PYTHONPATH
in the environmental variables section, which did not work .
So, is there any way where I can temporarily append the new path/s,
where the PythonWin interpreter would look during run time and discard
after the interpreter is closed.
For example, my main program "ATS.py" will be put in the folder
D:\\dSPACE\ATS\ and my modules will be put in other folders inside the
folder ATS, D:\\dSPACE\ATS\ Level Regulation, D:\\dSPACE\ATS\ Curve
Detection and so on.
So, I would like to tell the interpreter to look in to these folders to
import the modules.
Is that possible???
Regards,
Mohan
At Friday 15/12/2006 06:46, mohan wrote:
>To revert back to my question, I wanted to add a new path to my PythonWin IDE to access modules which are in folders other than normal python paths. Here, I need to put my modules in different folders since it is a request of the user. I tried to create a new PYTHONPATH in the environmental variables section, which did not work .
You can do that directly inside PythonWin, using the Tools menu.
>So, is there any way where I can temporarily append the new path/s, where the PythonWin interpreter would look during run time and discard after the interpreter is closed.
You could modify sys.path at runtime, appending directories if
needed. But the package solution below is much better.
>For example, my main program "ATS.py" will be put in the folder D:\\dSPACE\ATS\ and my modules will be put in other folders inside the folder ATS, D:\\dSPACE\ATS\ Level Regulation, D:\\dSPACE\ATS\ Curve Detection and so on.
So, I would like to tell the interpreter to look in to these folders to import the modules.
First, remove all spaces from directory names. Then make them normal
packages (an empty __init__.py may be enough) so you can write, in ATS.py:
from LevelRegulation import whatever
from CurveDetection.MyModuleName import MyClass
etc.
--
Gabriel Genellina
Softlab SRL
__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ˇgratis!
ˇAbrí tu cuenta ya! - http://correo.yahoo.com.ar This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Martin Bless |
last post by:
IMHO PythonWin is great help in developing.
How can I do something like:
if detect("running on PythonWin"):
pass
# fake arguments ...
else:
"proceed normal"
|
by: Henrik Weber |
last post by:
Hi.
I have tried to add pychecker as an extension to pythonwin. Now I can
have pychecker check the source file that is currently open in the
editor with a single keypress. If someone is...
|
by: r.e.s. |
last post by:
I have no PYTHONPATH nor any other python-related environment
variables, yet everything seems fine. (I'm using PythonWin
with winxp.) As long as modules are loaded through PythonWin,
is...
|
by: tkpmep |
last post by:
I have a Python program that collects user input using
msg = "Enter the full path and name of the file to be processed: "
answer = raw_input(msg)
If I run it in IDLE, the question is splashed...
|
by: Joseph Turian |
last post by:
Hi,
What is the safest manner to extend search path for modules, minimizing
the likelihood of shooting oneself in the foot?
The system (which includes scripts and their shared modules) may be...
|
by: rodrigostrauss |
last post by:
Having the following code:
==== Module1.py ====
import logging
def X():
logging.error('test')
If I import it into PythonWin console and call X(), the error message
is not printed. If I do...
|
by: leegold |
last post by:
Hi,
I run a script in PythonWin and obviously some sort of an error occurs
in the script and PythonWin closes. No warning, no error message just
closes. I definitely know the line of code that...
|
by: Martin P. Hellwig |
last post by:
Hello all,
I had some troubles in the past how to arrange my packages and modules,
because I usually don't develop my stuff in the Lib\site-packages
directory I have some troubles when importing...
|
by: sterling |
last post by:
I'm curious as to why the difference between IDLE and pythonWin when
using win32com.
opening an excel file, i've attempted to grab the chart information
out of the file.
commands like co =...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made but the http to https rule only works for...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
header("Location:".$urlback);
Is this the right layout the...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
| |