Configure python model in xampp - python

I installed mod_python, I try to run python script like:
from mod_python import apache
It show me the error message:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
from mod_python import apache
File "D:\Python27\lib\mod_python\apache.py", line 55, in <module>
import _apache
ImportError: No module named _apache
I don't know why?
My enviroment:
Windows XP, Python 2.7.2

If you don't get any help here, try the mod_python mailing list:
http://www.modpython.org/live/mod_python-2.7.8/doc-html/installation.html

Its probably that the script location is not added to your path.
try:
import sys
sys.path
sys.path.append('/path/to/the/mod_python.py')
If this doesn't work, it was probably not installed correctly.
If you want to add it to your system path permanently so you don't have to use the code above every time check out this SO question.

Related

python virtualenv cant seem to find modules even though they've already been installed

I am trying to run my python app on my website, and so I've created a virtual environment for all of the packages, and I've correctly installed all of the packages I need. When I check on the file path to my installed packages, they are all pointing to the correct path, and when I got to my site-packages file that they point to, they are all there.
However,
Every time I try to run my app, I get this:
stdin: is not a tty
Traceback (most recent call last):
File "/opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/wsgi-loader.py", line 369, in <module>
app_module = load_app()
File "/opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/wsgi-loader.py", line 76, in load_app
return imp.load_source('passenger_wsgi', startup_file)
File "/home/dsmproto/testblockchain/passenger_wsgi.py", line 1, in <module>
import main as application
File "/home/dsmproto/testblockchain/main.py", line 2, in <module>
from wallet import wallet
File "/home/dsmproto/testblockchain/wallet.py", line 1, in <module>
from Cryptodome.PublicKey import RSA
ImportError: No module named Cryptodome.PublicKey
I know that the module is there, but for some reason it is still saying there's no module.
Is there a command I can use in my SSH to check where my app is looking for modules?
All of the modules I have installed are installed correctly. Furthermore, when I open the SSH and run python commands in the terminal, they are able to import all of the modules without any issues.
So how come my app can't find these modules? Is there a way to check to make sure they are looking in the right place?
Thanks in advance for the help
EDIT:
I ran a script in python to look at the sys.path and got this:
/opt/alt/python38/lib64/python38.zip
/opt/alt/python38/lib64/python3.8
/opt/alt/python38/lib64/python3.8/lib-dynload
/home/dsmproto/virtualenv/testblockchain/3.8/lib64/python3.8/site-packages
/home/dsmproto/virtualenv/testblockchain/3.8/lib/python3.8/site-packages
Those are the correct folders that my packages are installed in, yet when I try to run my app, it still says it can't find them.

Updated Windows and now I can't import ssh2.session?

Working on code that SSH's into terminal on an external device. This morning the code was able to do so. Then I updated Windows because I had put it off for a while. This was the only thing I did that I could think of may have had an effect.
I now run into a ModuleNotFoundError.
I tried updating pip, uninstalling and reinstalling ssh2-python. I changed python37 folder to read/write. Tried locating the module in python37/Lib/site-packages but not really sure what I'm looking for
SSH's into address' terminal
import socket
from ssh2.session import Session
Expected:
input for ip address
Result:
Traceback (most recent call last):
File "C:/Users/louis/Desktop/ssh2.py", line 4, in <module>
from ssh2.session import Session
File "C:\Users\louis\Desktop\ssh2.py", line 4, in <module>
from ssh2.session import Session
ModuleNotFoundError: No module named 'ssh2.session'; 'ssh2' is not a package
I had named a file in the same directory ssh2. Python loaded that instead of the module. Simply renamed the file to anything else and python was able to find the ssh2 module.

run nupichelloworld in pycharm

I want to run nupichelloworld (https://github.com/lonesword/nupichelloworld) within pycharm but can't figure out how to force it to see nupic libraries. All sources -- nupic.core, nupic.sources, nupichelloworld etc are located on the same level (/home) (I am using the NUPIC-03-11-2014 image which I took from
https://mega.co.nz).
When I try to run it in console, that's all right, but pycharm tells following:
/usr/bin/python2.7 /home/nupic/nupichelloworld/helloworld.py
Traceback (most recent call last):
File "/home/nupic/nupichelloworld/helloworld.py", line 22, in <module>
import nupic
ImportError: No module named nupic
there is the such imports in the file:
from nupic.research.spatial_pooler import SpatialPooler as SP
import numpy as np
How to solve it? Thanx!
You probably need to configure the project's interpreter paths to include your package.

Tried to import _mysql through MySQLdb and get the error

I'm trying to use MySQLdb and when I try to import it I get the following error. Any thoughts? I'm currently using an ubuntu instance on aws.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/pymodules/python2.6/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory
>>>
Is libmysqlclient-dev installed? Package might not be exact, but thats the general idea.
Is this comment thread of any help?
Try updating /etc/ld.so.conf so as to include the directory in which you've installed this.
After struggling with this same issue myself (on the AWS Linux I AMI), I found the answer
here:
While the comment thread already posted was helpful, Apache was clearing my environment variables, so setting LD_RUN_PATH and/or LD_LIBRARY_PATH was not effective.
What ended up working was adding a new include statement to /etc/ld.so.conf and running ldconfig.

Why do I receive an ImportError when running one of the CherryPy tutorials

I have installed CherryPy 3.1.0,. Here is what happens when I try to run tutorial 9:
$ cd /Library/Python/2.5/site-packages/cherrypy/tutorial/
$ python tut09_files.py
Traceback (most recent call last):
File "tut09_files.py", line 48, in <module>
from cherrypy.lib import static
ImportError: cannot import name static
The previous line in the file:
import cherrypy
passes without error, so it appears that it can find cherrypy on the path. What am I missing?
This works for me, and I'm also using CherryPy 3.1.0, so I'm not sure what to tell you.
Look in your /Library/Python/2.5/site-packages/cherrypy/lib directory for a file named static.py; if this file exists then I'm not sure what to tell you. If it doesn't then something has happened to your CherryPy and I'd advise you to reinstall. If it does then you should check the value of sys.path to make sure it's detecting the right version of CherryPy.
You can also try running the python interpreter on the command line and then doing a from cherrypy.lib import static to see if you get the same result.
I had an old CherryPy-2.3.0-py2.5.egg file in my site-packages. After removing the old .egg I could run the tutorial.

Categories

Resources