473,287 Members | 1,395 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

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:
/Robbie/PythonWork

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.

-Robbie
Jun 27 '08 #1
3 1077
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.framework/Versions/2.5/lib/python2.5/site-
packages/
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.sysconfig 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

3
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...
0
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...
16
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...
0
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...
8
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...
3
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); ...
6
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...
7
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...
0
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...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.