| | |
How to permenantly set PYTHONPATH for 2.6 and 3.0?
Thread Solved |
•
•
Join Date: Sep 2009
Posts: 9
Reputation:
Solved Threads: 0
So I did some research and learn that you use the sys module to set the path for 2.5:
import sys
sys.path.append('usr/local/lib/python2.5/site-packages/')
And that would set the path for 2.5 permanently, but if i do the samething for 2.6 or 3.0, it will not work the next time I open the interpreter.
I thought this path was suppose to be set by default. it's not so i'm trying to set it.
help please
thanks
import sys
sys.path.append('usr/local/lib/python2.5/site-packages/')
And that would set the path for 2.5 permanently, but if i do the samething for 2.6 or 3.0, it will not work the next time I open the interpreter.
I thought this path was suppose to be set by default. it's not so i'm trying to set it.
help please
thanks
0
#2 28 Days Ago
You can get the path to the site-packages directory like this
With python 3:
(on the same machine).
However, you shouldn't normally need to put the site-packages in sys.path yourself. I'd like to see the value of your sys.path just after you start python.
python Syntax (Toggle Plain Text)
>>> import os >>> os.path.join(os.path.split(os.__file__)[0], "site-packages") '/usr/lib64/python2.6/site-packages'
python Syntax (Toggle Plain Text)
>>> import os >>> os.path.join(os.path.split(os.__file__)[0], "site-packages") '/usr/local/lib/python3.1/site-packages'
However, you shouldn't normally need to put the site-packages in sys.path yourself. I'd like to see the value of your sys.path just after you start python.
•
•
Join Date: Sep 2009
Posts: 9
Reputation:
Solved Threads: 0
0
#3 28 Days Ago
•
•
•
•
You can get the path to the site-packages directory like this
With python 3:python Syntax (Toggle Plain Text)
>>> import os >>> os.path.join(os.path.split(os.__file__)[0], "site-packages") '/usr/lib64/python2.6/site-packages'
(on the same machine).python Syntax (Toggle Plain Text)
>>> import os >>> os.path.join(os.path.split(os.__file__)[0], "site-packages") '/usr/local/lib/python3.1/site-packages'
However, you shouldn't normally need to put the site-packages in sys.path yourself. I'd like to see the value of your sys.path just after you start python.
"No module name file.py" after i did what you wrote and attempted to image a module
0
#6 27 Days Ago
What Gribouillis means is run this code and post the output here on DaniWeb ...
You need to run this with the version of Python you are interested in.
Also you cannot permanently set PYTHONPATH as it includes information about the current file you are working with.
python Syntax (Toggle Plain Text)
# show the system path for Python ( PYTHONPATH ) import sys print( sys.path )
Also you cannot permanently set PYTHONPATH as it includes information about the current file you are working with.
Last edited by vegaseat; 27 Days Ago at 4:02 pm. Reason: this
May 'the Google' be with you!
•
•
Join Date: Sep 2009
Posts: 9
Reputation:
Solved Threads: 0
0
#8 27 Days Ago
>>> import sys
>>> sys.path
['/home/junlue', '/usr/bin', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/var/lib/python-support/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/var/lib/python-support/python2.6/gtk-2.0', '/usr/local/lib/python2.6/dist-packages']
This is what i got. no site-pakcages though
>>> sys.path
['/home/junlue', '/usr/bin', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/var/lib/python-support/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/var/lib/python-support/python2.6/gtk-2.0', '/usr/local/lib/python2.6/dist-packages']
This is what i got. no site-pakcages though
0
#9 27 Days Ago
I suggest that you write a module
and put this module somewhere on your python path. Then when you write a python program, you simply put
This should work even if you have different versions of python.
python Syntax (Toggle Plain Text)
# mystartup.py import os, sys site_packages = os.path.join(os.path.split(os.__file__)[0], "site-packages") sys.path.append(site_packages)
python Syntax (Toggle Plain Text)
# at the top of your main program import mystartup
Last edited by Gribouillis; 27 Days Ago at 7:44 pm.
•
•
Join Date: Nov 2009
Posts: 1
Reputation:
Solved Threads: 1
It's quicker to get the path to site-packages right from the command line:
Python Syntax (Toggle Plain Text)
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
Last edited by prouty; 17 Days Ago at 1:28 pm. Reason: needed [code]
![]() |
Similar Threads
- Insert a struct in a set (C++)
- Trying to set up wireless lan (Networking Hardware Configuration)
- Airport Base Station Set Up??? (OS X)
- How can I set up my own email a/c with a domain name using microsoft outlook/express (Web Browsers)
- best chip set anyone? (Motherboards, CPUs and RAM)
- Set Precision in C++.NET? (C++)
- New Portal set up (DaniWeb Community Feedback)
Other Threads in the Python Forum
- Previous Thread: loops and parameters?
- Next Thread: List convert to string
| Thread Tools | Search this Thread |
address aliased anydbm app beginner bits calling casino changecolor cipher clear conversion coordinates corners cturtle curves definedlines development dictionary dynamic events excel external feet file float format function generator getvalue handling homework iframe images import input ip java keycontrol line linux list lists loan loop maintain matching maze millimeter mouse multiple number numbers output parsing path prime programming py py2exe pygame pymailer python queue random rational raw_input recursion recursive scrolledtext searchingfile signal singleton slicenotation split string strings tails text threading time tlapse tooltip tuple tutorial type ubuntu unicode url urllib urllib2 valueerror variable variables vigenere web whileloop word wxpython xlwt






