473,395 Members | 1,616 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,395 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 1079
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...

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.