Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6332659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:18:22+00:00 2026-05-24T18:18:22+00:00

So, I want to run a Python program with a home-directory install of PyProj

  • 0

So, I want to run a Python program with a home-directory install of PyProj from PHP. The PHP and Python are simple, but I include them below for completeness.

I’ve tested running Python manually using both sys.path.append and PYTHONPATH to specify the location of the package. Both of these methods work.

However, when I shell_exec the script from PHP, I’m told ImportError: No module named pyproj.

A recursive check of the file system reveals that everything is read/executable by user, group, and other.

Any thoughts on why this I can’t get this to run?

I’m calling it in a PHP script as follows

<?php
        putenv('PYTHONPATH="/home/userperson/public_html/lib64/python2.4/site-packages"');
        $ret=shell_exec("./bob");
        print $ret;
?>

The Python program is simple.

#!/usr/bin/python
import pyproj
import sys
sys.path.append("/home/userperson/public_html/lib64/python2.4/site-packages")
surfproj = pyproj.Proj(proj='lcc',lat_1=40,lat_2=50,lon_0=-95,lat_0=40,ellps='WGS84')
x,y=surjproj(-95,45)
print x
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:18:24+00:00Added an answer on May 24, 2026 at 6:18 pm

    A good way to solve a problem like this is to print the sys.path from a Python script in this environment and check what the current path is:

     #!/usr/bin/python
     import sys
     print sys.path
    

    My guess is that it will containt '"/home/userperson/public_html/lib64/python2.4/site-packages"' (note the superfluous double quotes).

    The documentation of putenv($setting) doesn’t say anything about supporting shell syntax, quotes or escaping inside the setting, so any characters present in the strings would no doubt end in the value of the environmental variable. A possible fix for the issue would be:

    putenv('PYTHONPATH=/home/userperson/public_html/lib64/python2.4/site-packages');
    

    Another useful hint would be to put the path in a separate variable, and just do putenv("PYTHONPATH=$pythonpath") or putenv("PYTHONPATH=" . implode(':', $pythonpath)), as this would allow you to check if the paths exist from your PHP script with file_exists.

    Older versions of PHP might have issue if safe_mode is enabled and PYTHONPATH isn’t in the safe_mode_allowed_env_vars, but hopefully you’re not running on a server configured like that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to run a command line program from within a python script and
I have a python program/file that I want to run repeatedly and calculate the
I want to run a python script from within another. By within I mean
I have a working Python based program that I want to run as a
i am using python C++ API to run python commands from C++ program. I
I have a python program I want to install into my virtualenv - it's
I want to be able to run my Python project from the command line.
I'm running Python 3.2 on Windows. I want to run a simple CGI server
I have a program that is run from the command line like this python
I've written two python scripts script1.py and script2.py. I want to run script1.py from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.