Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Home Directory
#1
Hi Guys and Gals,

I'm running Python on Windows 10 with XAMPP and it works fine so far. Now I want to use pie charts and I have to get some modules working (fe plotnine) but every time I get: "RuntimeError: Can't determine home directory" in the Apache log. I can't seem to find where it goes wrong. Please help.

Kind regards,
Patrick
Reply
#2
A advice XAMPP is never needed for Python,i would not use it all now(i did use XAMPP many year ago when Python was not so strong in web-development).
Just look at What is XAMPP?
Quote:XAMPP is the most popular PHP development environment
You do not see a Python reference.

The modern way of working with web-development in Python is to use eg Flask, Django.
Both of this comes with build in local web-server(then no need to web-server in XAMPP at all).

So if i was using plotnine and wanted pie charts is browser i would use Flask.
The other way could be to use Jupyter Notebook JupyterLab,then share notebook online is easy.
Reply
#3
Thank you for your reply but I use XAMPP als for php development. So is there a solution for the error I receive apart from Flask?
Reply
#4
So you run PHP with web-server from XAMPP,then try to integrate plotnine a Python librarian to run in your in web-app/site?
For the error not sure as you have not explained what tool or code you use(i guess over),only that you want to use plotnine.
It looks like XAMPP/Apache config problem,then search solution for that as most on this forum do not use XAMPP.
Reply
#5
All the python code I write works except the pie charts or plots. I did not find any solution on the forum. The errormessage is:

Error:
File "C:\\python37\\lib\\pathlib.py", line 263, in gethomedir\r: C:/xampp/htdocs/index.py, referer: https://localhost/zoeken.py raise RuntimeError("Can't determine home directory")\r: C:/xampp/htdocs/index.py, referer: https://localhost/zoeken.py RuntimeError: Can't determine home directory\r: C:/xampp/htdocs/index.py, referer: https://localhost/zoeken.py
This is the code in python:
import numpy as np
from bqplot import pyplot as plt

plt.figure(1, title='Line Chart')
np.random.seed(0)
n = 200
x = np.linspace(0.0, 10.0, n)
y = np.cumsum(np.random.randn(n))
plt.plot(x, y)
plt.show()
And the output looks like:
click here
Reply
#6
bqplot
Quote:Plotting library for IPython/Jupyter Notebooks
2-D plotting library for Project Jupyter
So this plotting library need a NoteBook environment,will not work stand alone.
Reply
#7
Ok, cheers.
Reply
#8
You can make your own web-server with Python.
Here with flask and matplotlib as example:


import io
import numpy as np
import matplotlib.pyplot as plt
from flask import Flask
from flask import send_file


app = Flask(__name__)


@app.route('/')
def root():
    n = 200
    x = np.linspace(0.0, 10.0, n)
    y = np.cumsum(np.random.randn(n))
    plt.plot(x, y)
    file = io.BytesIO()
    plt.savefig(file, format='png')
    file.seek(0)
    return send_file(file, mimetype='image/png')


app.run()
Later you can let run uwsgi to handle the Python the processes.
On top you can put the apache2 or better nginx.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#9
Hi I have the same problem. I'm running Python on Windows 10 with XAMPP and it works fine so far. Now I want to use pie charts and I have to get some modules working (fe plotnine) but every time I get: "RuntimeError: Can't determine home directory" in the Apache log
Reply
#10
Here is some information:
https://stackoverflow.com/questions/4270...with-xampp

Using XAMPP together with Python is sh...
The ability to debug is not the best and for each call a new Python interpreter is fired up.

If you want to learn how to do it wrong, then use Apache 2 + Python CGI.
The other problem is how Windows find the right Python interpreter.
I've installed more than one, but Apache want to use Stackless Python 2.7 which I've installed and which is somewhere in the Path environment variable.

In my case, Apache 2 just ignores the header in the python source code, where I set the right interpreter.

You don't even need an Apache 2 server for developing websites in Python.
The most people who are using Python in production, are using it behind a nginx as reverse proxy.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  simple code: change to home directory Skaperen 5 3,496 Sep-10-2018, 10:29 AM
Last Post: buran
  change to home directory Skaperen 2 2,535 Nov-28-2017, 02:53 AM
Last Post: Skaperen
  change to home directory Skaperen 4 11,463 Apr-20-2017, 05:54 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020