django.fcgi or virtualenv : no module named operator - python

So these are my website informations:
framework : Django
hosting : alwaysdata
python : 2.7
virtualenv is used
The problem :
I have the non explicit 500 error :Internal Server Error
I have not any error log
But :
I found a trail to solve this issue. Indeed when i run manually the django.fcgi, i got this traceback:
Traceback (most recent call last):
File "public/django.fcgi", line 14, in
from django.core.servers.fastcgi import runfastcgi
File "/home/usr/.virtualenvs/thevirtualenv/lib/python2.7/site-packages/django/core/servers/fastcgi.py", line 17, in
from django.utils import importlib
File "/home/usr/.virtualenvs/thevirtualenv/lib/python2.7/site-packages/django/utils/importlib.py", line 4, in
from django.utils import six
File "/home/usr/.virtualenvs/thevirtualenv/lib/python2.7/site-packages/django/utils/six.py", line 23, in
import operator
ImportError: No module named operator
Manipulation(s) which could occur this issue :
I had this issue for 3 week ago, i let it rest too long, so now i can't remember what i have done to bring about this.. But i think it was a dirty virtualenv creation or edition, something like that..
Thanks to bear with my english.
Does anyone have an Idea about my case?
Attempts to solve this issue:
I just tried to recreate my virtualenv and got this error message :
Traceback (most recent call last):
File "/home/usr/python/python27/bin/virtualenv", line 5, in
from pkg_resources import load_entry_point
zipimport.ZipImportError: can't decompress data; zlib not available

Since the operator module is part of the standard library, it looks like you have a corrupt Python installation in your virtualenv. The best thing to do would be to simply delete and recreate your virtualenv.

Related

How to change the path where Jupyter looks for libraries

I have python 3.10 installed on disk C: and Anaconda with Python 3.9 on disk D:. When I try importing numpy in jupyter, I get the following error.
>>> import numpy
Traceback (most recent call last):
File "C:\Python310\Lib\site-packages\numpy\core\__init__.py", line 23, in <module>
from . import multiarray
File "C:\Python310\Lib\site-packages\numpy\core\multiarray.py", line 10, in <module>
from . import overrides
File "C:\Python310\Lib\site-packages\numpy\core\overrides.py", line 6, in <module>
from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python310\Lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import core
File "C:\Python310\Lib\site-packages\numpy\core\__init__.py", line 49, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.9 from "D:\ProgramData\Anaconda3\python.exe"
* The NumPy version is: "1.23.3"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
Looks like Python interpreter from disk D: is looking for libraries in disk C:, and I suppose that the numpy file installed there is not compatible with python 3.9. I think it's because my PYTHONPATH is
>>> print("PYTHONPATH:", os.environ.get('PYTHONPATH'))
PYTHONPATH: C:\Python310\Lib\site-packages
But how do I change it so that Jupyter only looks for what's in Anaconda folder libraries and not break whatever I have on disk C:? I guess what I'm asking is, is it possible to have 2 PYTHONPATHs, one for Jupyter and one for whatever else? Would it be sufficient to just add Anaconda libraries folder to PYTHONPATH, or it would cause conflicts? Because how would Jupyter choose one path over the other?

Python Path error - No Module Found error

I'm having issues running ortools on Linux. I downloaded it from google's site (https://developers.google.com/optimization/) and installed it using "make install," but when I go to use it in python I get the following:
Traceback (most recent call last):
File "regular.py", line 42, in <module>
from ortools.constraint_solver import pywrapcp
File "/home/m3/summer/ortools_examples/examples/python/ortools.py", line 2, in <module>
ImportError: No module named linear_solver
It looks like despite installing ortools, its still not in my python path correctly, so when I call it in the file, it doesn't find anything and returns an error, right? Any advice on how to solve this?

Graphite install error 0.10.0-alpha

I get the following error when starting Graphite-web using DJango.
0.9.15 works ok, but I am looking to use the new "mapSeries" function available in 0.10.x
Seems to be a missing import -
Exception occurred processing WSGI script '/opt/graphite/conf/graphite.wsgi'.
Traceback (most recent call last):
File "/opt/graphite/conf/graphite.wsgi", line 46, in <module>
import graphite.metrics.search # noqa
File "/opt/graphite/webapp/graphite/metrics/search.py", line 6, in <module>
from graphite.storage import is_pattern, match_entries
ImportError: cannot import name match_entries
I'm not a python programer, but maybe the package is missing in the setup.py?
https://github.com/graphite-project/graphite-web/blob/master/setup.py
I solved the issue by updating /opt/graphite/conf/graphite.wsgi to the latest example version.
The 0.9.x version is not compatible with 0.10.x

Pystacia can't find MagickWand on OS X

For some odd reason Pystacia is not able to find MagickWand.h on OS X.
I tried to tweak $DYLD_LIBRARY_PATH and $C_INCLUDE_PATH but no luck.
I have imagemagick up and running.
$ mdfind MagickWand.h
/usr/local/Cellar/imagemagick/6.8.010/share/doc/ImageMagick/www/api/MagickWand/struct__MagickWand.html
/usr/local/Cellar/imagemagick/6.8.0-10/include/ImageMagick/wand/MagickWand.h
And keep getting this error:
>>> import pystacia
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/pystacia/__init__.py", line 193, in <module>
init()
File "/Library/Python/2.7/site-packages/pystacia/__init__.py", line 28, in init
raise TinyException('Could not find or load magickWand')
pystacia.util.TinyException: Could not find or load magickWand
I went further down to figure it out how pystacia looks for MagickWand.h:
from ctypes.util import find_library
resolved_path = find_library('MagickWand')
if not resolved_path:
raise PystaciaException('Could not find or load magickWand')
Still no lucky.
Looking to the latest pystacia code from bitbucket I realized that the version from pip is pretty old (from 2011) and a installation from the latest code solved my problem -- as I can afford to run unreleased code.
I also entered an Issue on bitbucket so the maintainer put out a new code release.

ImportError: couldn't find library

I am encountering these errors frequently when I install python libraries and I'm wondering what I am doing wrong
the current example is the libchromaprint library
http://acoustid.org/chromaprint
I install it and everything, try to run the python example, get:
Traceback (most recent call last):
File "examples/fpwav.py", line 7, in <module>
import chromaprint
File "build/bdist.linux-x86_64/egg/chromaprint/__init__.py", line 24, in <module>
ImportError: couldn't find libchromaprint
and then when I check:
find /usr/local/lib/libch*
/usr/local/lib/libchromaprint.so
/usr/local/lib/libchromaprint.so.0
/usr/local/lib/libchromaprint.so.0.1.3
what am I doing wrong?
Python does not use your usual library path. The chromaprint you're looking for should be somewhere like /usr/lib/pymodules/python2.6.
From the python interpreter do:
>>> import sys
>>> sys.path
This will show you the directories python searches for a module.

Categories

Resources