Help setting PYTHONHOME and PYTHONPATH

This is the place for queries that don't fit in any of the other categories.

Help setting PYTHONHOME and PYTHONPATH

Postby RedEyedDog1 » Fri Oct 11, 2013 9:36 am

Please some one explain how and where these are meant to be set to :(
RedEyedDog1
 
Posts: 17
Joined: Thu Oct 10, 2013 11:21 am

Re: Help setting PYTHONHOME and PYTHONPATH

Postby metulburr » Fri Oct 11, 2013 1:17 pm

I believe you might rather mean setting the path env variable?

Have you read the tutorial executing python?
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1387
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Help setting PYTHONHOME and PYTHONPATH

Postby RedEyedDog1 » Fri Oct 11, 2013 2:25 pm

Im using linux sorry, that tutorial is for windows
RedEyedDog1
 
Posts: 17
Joined: Thu Oct 10, 2013 11:21 am

Re: Help setting PYTHONHOME and PYTHONPATH

Postby Marbelous » Fri Oct 11, 2013 3:03 pm

http://www.tutorialspoint.com/python/py ... onment.htm

There is no specific list of paths that PYTHONPATH is meant to be. The sys.path variable holds the defaults. Try:
Code: Select all
>>> import sys
>>> print sys.path  # Print the current list of paths that python will look through for modules.
['C:\\Python27\\Lib\\idlelib', 'C:\\Windows\\system32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages']
>>> 

Appending your own folder paths to the list will extend the search:
Code: Select all
>>> sys.path.append('C:\\MyPython\\code')
>>> sys.path
['C:\\Python27\\Lib\\idlelib', 'C:\\Windows\\system32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages', 'C:\\MyPython\\code']
>>>


PYTHONHOME is the just the default location of the python libraries. It shouldn't be changed unless you're doing some sort of custom installation.

From the Python Docs:
PYTHONHOME
Change the location of the standard Python libraries. By default, the libraries are searched in prefix/lib/pythonversion and exec_prefix/lib/pythonversion, where prefix and exec_prefix are installation-dependent directories, both defaulting to /usr/local.

When PYTHONHOME is set to a single directory, its value replaces both prefix and exec_prefix. To specify different values for these, set PYTHONHOME to prefix:exec_prefix.

PYTHONPATH
Augment the default search path for module files. The format is the same as the shell’s PATH: one or more directory pathnames separated by os.pathsep (e.g. colons on Unix or semicolons on Windows). Non-existent directories are silently ignored.

In addition to normal directories, individual PYTHONPATH entries may refer to zipfiles containing pure Python modules (in either source or compiled form). Extension modules cannot be imported from zipfiles.

The default search path is installation dependent, but generally begins with prefix/lib/pythonversion (see PYTHONHOME above). It is always appended to PYTHONPATH.

An additional directory will be inserted in the search path in front of PYTHONPATH as described above under Interface options. The search path can be manipulated from within a Python program as the variable sys.path.
Marbelous
 
Posts: 116
Joined: Fri May 31, 2013 8:12 pm

Re: Help setting PYTHONHOME and PYTHONPATH

Postby RedEyedDog1 » Fri Oct 11, 2013 3:57 pm

Hi thanks for the reply :) i get it now.

do you know where _lpython3.3 is located so i can add to the path, i think that is whats causing this error :

Code: Select all
root@debian:/home/halo11/Downloads/Python-3.3.2# make test
running build
running build_ext

Python build finished, but the necessary bits to build these modules were not found:
_bz2               _lzma                             
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

running build_scripts
copying and adjusting /home/halo11/Downloads/Python-3.3.2/Tools/scripts/pydoc3 -> build/scripts-3.3
copying and adjusting /home/halo11/Downloads/Python-3.3.2/Tools/scripts/idle3 -> build/scripts-3.3
copying and adjusting /home/halo11/Downloads/Python-3.3.2/Tools/scripts/2to3 -> build/scripts-3.3
copying and adjusting /home/halo11/Downloads/Python-3.3.2/Tools/scripts/pyvenv -> build/scripts-3.3
changing mode of build/scripts-3.3/pydoc3 from 644 to 755
changing mode of build/scripts-3.3/idle3 from 644 to 755
changing mode of build/scripts-3.3/2to3 from 644 to 755
changing mode of build/scripts-3.3/pyvenv from 644 to 755
renaming build/scripts-3.3/pydoc3 to build/scripts-3.3/pydoc3.3
renaming build/scripts-3.3/idle3 to build/scripts-3.3/idle3.3
renaming build/scripts-3.3/2to3 to build/scripts-3.3/2to3-3.3
renaming build/scripts-3.3/pyvenv to build/scripts-3.3/pyvenv-3.3
./python -E -c 'import sys ; from sysconfig import get_platform ; print(get_platform()+"-"+sys.version[0:3])' >platform
./python  ./Tools/scripts/run_tests.py
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
make: *** [test] Aborted
RedEyedDog1
 
Posts: 17
Joined: Thu Oct 10, 2013 11:21 am

Re: Help setting PYTHONHOME and PYTHONPATH

Postby metulburr » Fri Oct 11, 2013 5:55 pm

What is the url of the tarball you are downloading that gives you this error?
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1387
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Help setting PYTHONHOME and PYTHONPATH

Postby RedEyedDog1 » Sat Oct 12, 2013 4:18 pm

Hi

Its http://www.python.org/ftp/python/3.3.2/ ... .2.tar.bz2

Id be really thankful if you can help with this :) i've been trying for a few days and cant seem to get to grips with Linux:(
RedEyedDog1
 
Posts: 17
Joined: Thu Oct 10, 2013 11:21 am

Re: Help setting PYTHONHOME and PYTHONPATH

Postby casevh » Sat Oct 12, 2013 5:50 pm

I normally have several versions of Python on my Linux system and I've never encountered this error message, nor have I ever had to modify PYTHONHOME and PYTHONPATH. My instructions assume PYTHONHOME and PYTHONPATH are not set.

Don't try to modify/change/overwrite the versions of Python provided by the distribution. You will most likely break their system of dependencies. If you install Python with my instructions, it will not be able to use any of the libraries, modules, etc. that are provided by your distribution. That may not be what you want.

Place your personalized version of Python in some other location. Historically, /usr/local was used for local installations but some distributions are placing their files in this directory. I normally create /opt/local and install my versions of Python there. Since I'm the only user of my computer, I change the ownership of /opt/local to my account instead of root.

I normally these steps.

Code: Select all
$ cd <<directory containing the source>>
$ make distclean
$ ./configure --prefix=/opt/local
$ make

If your account has read/write access to /opt/local, then you can install Python with

Code: Select all
$ make altinstall


If not, you will need to use

Code: Select all
$ sudo make altinstall


To avoid conflict with the command "python" or "python3" which are normally provided by the distribution, I create symbolic links to my versions. You will need to find a directory that is on your PATH (use "echo $PATH" from a terminal window). On my system, the last entry in the PATH is /home/<<my username>>/bin.

Code: Select all
$ ln -s /opt/local/bin/python3.3m /home/<<my username>>/bin/py33


py33 should now invoke your version of Python.

If a completely standalone version of Python isn't what you want, please state what you want to accomplish and not just the problems you're encountering.
casevh
 
Posts: 70
Joined: Sat Feb 09, 2013 7:35 am

Re: Help setting PYTHONHOME and PYTHONPATH

Postby RedEyedDog1 » Sat Oct 12, 2013 7:31 pm

Hi

My whole situation is this:

I need to know where the make file is that python3.3 is using so i can change the line where it is looking for lpython3.3 and not lpython3.3.m.

ive looked everywhere, ive looked in us/local/lib/python3.3/config-3.3m but cant find that line of code.

Do you know where it code be?
RedEyedDog1
 
Posts: 17
Joined: Thu Oct 10, 2013 11:21 am


Return to General Coding Help

Who is online

Users browsing this forum: snippsat and 3 guests