473,545 Members | 2,001 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Newbie Question: How to use a .pth file on a Macintosh

Hello All,

Hopefully this is an easy question: I'd like to use a .pth file on my
Macintosh so that I can easily import modules that I've created in my
own working directory. I've created a file called Robbie.pth. It
includes a single line:

I can't seem to figure out where to put this file so that Python will
recognize it when I start it up. I know that the path is correct
because if I do the command sys.path.append ('/Robbie/PythonWork') then
everything works as expected. I just don't want to have to execute
this command every time I start Python.

I've looked at what's in sys.path, and have tried putting the file in
various of the directories listed, to no avail. I've also tried
putting it in the same directory where IDLE is (/Applications/
MacPython 2.5) and that doesn't work either.

What am I missing?

FYI I'm running MaxOS 10.4.8 and Python 2.5,

Thank you in advance for the help.

Jun 27 '08 #1
3 1082
Hmmm, for lack of a better response, here are some suggestions, based
on what I've seen on Windows+Linux.

#1 put the .pth in the site-packages directory (this is what I do on
Linux). I think Python considers it special and looks for pth.

you can probably get that directory from doing

import sys
for i in sys.path:
print i

#2 put the .pth in the directory where the python executable is
located (this is less messy on Windows than on Linux or OS X)

which python (run on the OS X terminal command shell) should give you
an idea of where that is.

#3 Another idea is to use the Finder to find _other_ *.pth files that
may exist and put yours in the same location.

Best of luck.
Jun 27 '08 #2
you put your pth file in (same configuration:

/Library/Frameworks/Python.framewor k/Versions/2.5/lib/python2.5/site-
Jun 27 '08 #3
Robbie wrote:
I can't seem to figure out where to put this file so that Python will
recognize it when I start it up.
You need to put this file in your site-packages directory.
To get the location of your site-packages directory, type in Python
interactive shell:

from distutils.sysco nfig import get_python_lib
print get_python_lib( )

-- Ivan
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Gary Richardson | last post by:
I would like to define a new cursor for use on a Canvas (other than one of those listed in Appendix F of "Python and Tkinter Programming"). A search on Google turned up one bit of code that seemed promising. A slightly simplified version is shown below. This code attempts to eliminate the cursor by defining an invisible one, which is not what...
by: Tomas Eklund | last post by:
Using: Classic ASP, File System Object, IIS Once a day my ASP script compiles some data into a csv/text file which is sent by e-mail to the customer. This file is then imported into a FileMaker database on the client's computer. The client uses a Macintosh system. The problem is that on import into FileMaker most characters besides a-z...
by: nephish | last post by:
Hey there, kinda newbie question here. i know how to read the lines of a txt file. i know how to write a txt file. but how do i overwrite a line value with another value ? i mean, how do go to, say, line 3 of a text file and replace what is written on line 3 with something else?
by: Georg Christmann | last post by:
Hello everybody, I have recently started tinkering about with Python. If there are any Macintosh-based Python developers reading this newsgroup I would like to ask them one Macintosh-specific question: If you want to write GUI scripts on the Mac, say with Tkinter, you need to invoke "pythonw" instead of "python" and use "#!...
by: Bob Skutnick | last post by:
Greetings, I'm hoping someone has experienced a problem I'm having: I have an existing ASP application (working fine) that uses an SSL server certificate. My user community is made up of both PC's and Macintosh computers. I've re-written this application in ASP.NET for a number of reasons and now find that my Mac users are having...
by: Chen ShuSheng | last post by:
HI, I am now study a segment of codes: ------------------------ printf("%p\t",fp); /*add by me*/ fseek(fp, 0L, SEEK_END); /* go to end of file */ printf("%p\t",fp); /*add by me*/ last = ftell(fp); cout<<"last="<<last<<"\t"; /*add by me*/ -------------------------
by: spandya | last post by:
Hi friends, I need to import a web log file coming from apache server into a table.But the problem is that log file is in some strange format.Its not in a comma delimited or not a tab delimited. I am sending u some records of that file for a refrence. - - "GET http://zdpub.dl.llnw.net/flvplayer3.../c4/window4.jpg HTTP/1.0" 304...
by: lawrence k | last post by:
I've got a music studio for a client. Their whole studio is run with Macintosh computers. Macintosh computers allow file names to have open white spaces, such as "animal hospital.mp3". I have a download script, so customers on the website can download MP3s to their harddrive (rather than merely listen to it in their browsers):
by: =?Utf-8?B?U0NhcnRlcg==?= | last post by:
I am working on a project where I need to create an excel file from our ASP.Net website and have it saved on a Macintosh computer. Currently, it is saving the .xls file just fine on the MAC, but when you go to open it, it opens the file as a new workbook. When you go to save it, it tries to save it as the auto-generated workbook name that...
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...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
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...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.