简体   繁体   中英

Enthought Canopy: how do I add to the PATH?

Running Enthought Canopy appears to de-activate the normal .profile PATH information (OS X) for python programs run within the Canopy environment. I need to make locations searchable for user files.

How to do this is not explained in the user manual. There are several possible places to enter such information (eg the two 'activate' files) but adding extra PATH information in them has no effect.

So how is it done?

DN

On Mac OSX 10.6.8 this worked

% launchctl setenv PYTHONPATH /my/directory:/my/other/directory

then launch Canopy and you should see /my/directory and /my/other/directory on sys.path

This follows from the link to Setting environment variables in OS X? on the page posted by Jonathan. I had made a mistake with the command syntax in the file '/private/etc/launchd.conf'.

Creating or editing the file 'launchd.conf' (using an editor that is aware of permissions, eg BBEdit) in /private/etc with something like the following line:

setenv PYTHONPATH /Users/<username>/Python/:/Users/<username>/AnotherPath/ ,

for example, will create a variable PYTHONPATH that, after rebooting, Canopy sees.

It works for other environment variables, too. The launchd.conf file is all that's needed, and, what's even better, it appears to stick between boots.

The problem described also occurs in a Win 7 Canopy installation.

I tried to place files to be imported in several of the locations provided in sys.path().

['', 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\User\\Scripts\\python27.zip', 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\App\\appdata\\canopy-1.0.0.1160.win-x86_64\\DLLs', 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\App\\appdata\\canopy-1.0.0.1160.win-x86_64\\lib', 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\App\\appdata\\canopy-1.0.0.1160.win-x86_64\\lib\\plat-win', 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\App\\appdata\\canopy-1.0.0.1160.win-x86_64\\lib\\lib-tk', 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\App\\appdata\\canopy-1.0.0.1160.win-x86_64', 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\User', 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\User\\lib\\site-packages', 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\System', 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\System\\lib\\site-packages', 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\System\\lib\\site-packages\\PIL', 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\System\\lib\\site-packages\\win32', 'C:\\Users\\Owner\\AppData \\Local\\Enthought\\Canopy\\System\\lib\\site-packages\\win32\\lib', 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\System\\lib\\site-packages\\Pythonwin', 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\App\\appdata', 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\App\\appdata\\canopy-1.0.0.1160.win-x86_64\\lib\\site-packages', 'C:\\Users\\Owner\\AppData\\Local\\Enthought\\Canopy\\App\\appdata\\canopy-1.0.0.1160.win-x86_64\\lib\\site-packages\\IPython\\extensions']

The only solution I found was to use:

sys.path.append()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM