Is it possible to change the searchpath for modules on the flight,
under winXP ?
Most preferred is some command to extend the searchpath.
(the environment variable PYTHONPATH needs a reboot)
thanks,
Stef Mientki 9 2233
Stef Mientki <S.************ **@mailbox.kun. nlwrites:
Is it possible to change the searchpath for modules on the flight,
under winXP ?
Most preferred is some command to extend the searchpath.
(the environment variable PYTHONPATH needs a reboot)
Do you mean something like that?
>>import some_module
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named some_module
>>import sys sys.path.appe nd("..") import some_module
http://docs.python.org/tut/node8.htm...00000000000000
--
HTH,
Rob
Do you mean something like that?
>
>>>import some_module
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named some_module
>>>import sys sys.path.app end("..") import some_module
Rob,
thank you very much,
that's exactly what I want.
(Why is the obvious so often invisible to me ;-)
cheers,
Stef Mientki
Stef Mientki kirjoitti:
Is it possible to change the searchpath for modules on the flight,
under winXP ?
What do you mean by *on the flight*: inside IDLE? using the command line?
Most preferred is some command to extend the searchpath.
(the environment variable PYTHONPATH needs a reboot)
No, it doesn't. PYTHONPATH can be updated somewhere in the environment
options (sorry: I've got a Finnish language XP version, so I don't
remember the exact terms) and the new path comes in effect immediately
i.e. the launches after that see the new definition.
That way of changing the PYTHONPATH is a little difficult, though. In
command line usage i.e. CMD.EXE I have been using these kinds of bat
files to alternate between versions 2.4 and 2.5 of Python. (These were
suggested earlier by someone in this group I think):
===
Py24.bat (Py25.bat has Python25 instead of Python24 in it)
===
@echo off
if .%1.==.. goto NODEV
set DEMOHOME=%1
goto CONT
:NODEV
set DEMOHOME=C:
:CONT
set PYTHONHOME=%DEM OHOME%\Python24
set PYTHONPATH=%PYT HONHOME%;
set PYTHON=%PYTHONH OME%\python.exe
set PYTHONW=%PYTHON HOME%\pythonw.e xe
set PATH=%PYTHONHOM E%;%PATH%
===
Py.bat (to launch Python)
===
"%PYTHON%" "%1.py" "%2" "%3" "%4" "%5" "%6" "%7" "%8" "%9"
thanks,
Stef Mientki
HTH,
Jussi
Jussi Salmela wrote:
Stef Mientki kirjoitti:
>Is it possible to change the searchpath for modules on the flight, under winXP ?
What do you mean by *on the flight*: inside IDLE? using the command line?
No, I run Python, embedded from within a Delphi program.
>Most preferred is some command to extend the searchpath. (the environment variable PYTHONPATH needs a reboot)
No, it doesn't. PYTHONPATH can be updated somewhere in the environment
options (sorry: I've got a Finnish language XP version, so I don't
remember the exact terms) and the new path comes in effect immediately
i.e. the launches after that see the new definition.
Through "My computer" | properties | advanced | Environment Variables"
you have to reboot.
But as I remember well there should be a way, (through the registry or DOS-box ?)
but I don't want to mess in the registry,
I want to keep my application portable.
But the suggestion of Rob, looks perfect.
thanks anyway,
Stef Mientki
Through "My computer" | properties | advanced | Environment Variables"
you have to reboot.
The best overall solution is the one where you modify sys.path to add
your own custom paths, however Jussi is right in that you do not need
to reboot. You have to restart any applications that relies on using
the updated environment variables (in your case the Delphi program): http://www.microsoft.com/resources/d....mspx?mfr=true
Inca wrote:
>Through "My computer" | properties | advanced | Environment Variables" you have to reboot.
The best overall solution is the one where you modify sys.path to add
your own custom paths,
I agree, specially in my situation that is the best solution.
however Jussi is right in that you do not need
to reboot. You have to restart any applications that relies on using
the updated environment variables (in your case the Delphi program):
http://www.microsoft.com/resources/d....mspx?mfr=true
I think the problem comes from the Delphi interface,
both Idle and PyScripter reflect a change PYTHONPATH after a restart.
But my Delphi program needs a reboot :-(
I'll ask around in the Python4Delphi newsgroup.
cheers,
Stef Mientki
Stef Mientki wrote:
>Do you mean something like that?
>>>>import some_module
Traceback (most recent call last): File "<stdin>", line 1, in ? ImportError: No module named some_module
>>>>import sys sys.path.ap pend("..") import some_module
Rob,
thank you very much,
that's exactly what I want.
(Why is the obvious so often invisible to me ;-)
cheers,
Stef Mientki
Just a note, If you run the module from different location, it may not always
work.
The '..' is relative to the location you are running the module from, the
current directory, and not relative to the location of the module is at.
It won't be a problem for you if you can be sure the module is always ran from
the location it is at.
Cheers,
Ron
Just a note, If you run the module from different location, it may not
always work.
The '..' is relative to the location you are running the module from,
the current directory, and not relative to the location of the module is
at.
thanks for the tip Ron,
I didn't realized ".." was literal ;-)
so I've changed my application, so it inserts the absolute path.
cheers,
Stef
>
En Sat, 03 Feb 2007 14:25:31 -0300, Stef Mientki
<S.************ **@mailbox.kun. nlescribió:
Is it possible to change the searchpath for modules on the flight,
under winXP ?
Most preferred is some command to extend the searchpath.
(the environment variable PYTHONPATH needs a reboot)
PYTHONPATH is used to build the initial contents of sys.path, which is the
actual list of directories searched. It's a standard list object so you
can modify it easily.
--
Gabriel Genellina This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rami A. Kishek |
last post by:
Hi, I would really appreciate help on this from all ye Win-oriented
people. I have been using python under Linux for quite a while, know
little about windows.
I just upgraded my Python on WinME machine from Python 1.5.2 to 2.2.3
(in a separate directory). Using the Pythowin Pythonpath browser, I
edited the python path to add my scripts directories. Then I tried to
import my scripts and they're not visible. I tried many things:
-...
|
by: Eric Wichterich |
last post by:
Hello Pythonistas,
I am trying to get certain (self-written) libraries imported into my
scripts using statements like
"from library import function.py".
But they are not being found.
I think that the pythonpath-variable must be expanded to the location
|
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 PYTHONPATH unnecessary? Or am I missing something?
|
by: Tero Pihlajakoski |
last post by:
Hi,
I've been experimenting on embedding Python to a C software, and ran into
a little problem with PYTHONPATH (I'm running on linux). Here's the deal:
When trying to call PyImport_Import("xyz"), Python returns an error "No
module named xyz". The problem _seems_ to be that I had no PYTHONPATH
variable defined (though python-shell works ok regardless), since the
following in bash helps:
|
by: D Denholm |
last post by:
I recently installed Python 2.2 on my WinXP box.
I am having problems figuring out how to create the PYTHONPATH
correctly.
I went to the WinXP SystemProperties > Advanced > Environment
Variables and created a System Variable called PYTHONPATH with the
value:
G:\Python22\lib\site-packages\Pythonwin;
| |
by: sushant.sirsikar |
last post by:
Hi,
I am using Linux env.I set the PYTHONPATH using
import sys
sys.path.append(----)
But we i close python and start again i is not showing my new entry in
PYTHONPATH.
Can anyone help me to make my path persistant?
Thanks
|
by: Michael Yanowitz |
last post by:
Hello:
Someone on my team tried out installing my Python code and
found that setting PYTHONPATH does not work, but setting PATH
environment variable works the way PYTHONPATH should. Is that
how it supposed to be, or is that a bug or feature?
-----Original Message----- (parts deleted)
Subject: question on Python for windows
|
by: mhearne808[insert-at-sign-here]gmail[insert-dot-he |
last post by:
I'm missing something major here. I'm trying to add a directory to my
python path using the PYTHONPATH environment variable, and it's being
ignored by the Python interactive shell.
Below is a capture of what I did. Note that my newfolder appears
nowhere on the list of directories in sys.path. How do I get Python
to pay attention to my shell variables?
Using bash on OS X 10.4.10.
|
by: Aljosa Mohorovic |
last post by:
i have a working MySQLdb module (/usr/lib/python2.4/site-packages/
MySQL_python-1.2.2-py2.4-linux-i686.egg), using it without problems.
"clean shell" after login:
python -c "import MySQLdb" reports no errors
if i export PYTHONPATH:
export PYTHONPATH=/var/www/projects/uv_portal/portal
python -c "import MySQLdb" reports no errors as in previous case
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |