import special module error - python-2.7

I am using python2.7.6. When I run this order:
import scipy.special as S
I get this error:
File "/home/liaoya/.local/lib/python2.7/site-packages/scipy/special/__init__.py", line 546, in <module>
from ._ufuncs import *
ImportError: libifport.so.5: cannot open shared object file: No such file or directory
How should I fix this?

Related

No module named 'django.contrib.admin.templatetags.admin_static'

my django version is 3.0.5 and django-suit version is 0.2.28 but why does this error happen?
the whole error information is as follows:
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\suit\admin.py", line 8, in <module>
from suit.widgets import NumberInput, SuitSplitDateTimeWidget
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\lib\site-packages\suit\widgets.py", line 6, in <module>
from django.contrib.admin.templatetags.admin_static import static
ModuleNotFoundError: No module named 'django.contrib.admin.templatetags.admin_static'
I solved the problem.
Modify this fileļ¼š \Python38\Lib\site-packages\suit\widgets.py
# from django.contrib.admin.templatetags.admin_static import static
from django.contrib.admin import static
then rerun your program, maybe met problem below:
File "D:\Work_Station\Python38\lib\site-packages\suit\templatetags\suit_menu.py", line 17, in <module>
string_types = basestring,
NameError: name 'basestring' is not defined
modify the file : Python38\lib\site-packages\suit\templatetags\suit_menu.py
# from django.utils.six import string_types
from six import string_types

Python 2.7 Py2exe with Tkinter and matplotlib

I'm trying to create an executable using py2exe for my Tkinter widget using python 2.7. This is my setup.py file:
from distutils.core import setup
import Tkinter
import py2exe
import numpy
import matplotlib
import scipy
import FileDialog
includes = ['scipy.special._ufuncs_cxx',
'scipy.sparse.csgraph._validation'
]
#dll_excludes = ['libgdk-win32-2.0-0.dll','libgobject-2.0- 0.dll','libgdk_pixbuf-2.0-0.dll']
setup(
console=["home.py"]
,options={"py2exe":{'includes':includes
# ,'packages' : ['matplotlib','pytz']
# ,'dll_excludes': dll_excludes
}
}
,data_files=matplotlib.get_py2exe_datafiles()
)
The executable compiles fine, but when I try to run home.exe from the dist folder it gives me this message.......and I have no idea how to fix it (I thought doing import FileDialog would do it):
File "matplotlib\backends\backend_tkagg.pyc", line 7, in <module>
File "six.pyc", line 194, in load_module
File "six.pyc", line 108, in _resolve
File "six.pyc", line 79, in _import_module
ImportError: No module named FileDialog
Thanks very much

Shelve import module error python 2.7

I try to import a custom Class Instance that I shelved but I am getting an:
Import Error: No module named MyModule
All my python modules are located within a directory that contains __init__.py
Here is my puttoshelve.py template to perform the shelve:
from MyModule import MyModule
import shelve
import copy
mymodule = MyModule()
cmymodule = copy.deepcopy(mymodule)
pathtomyshelve ="/some/path/shelve"
cshelve = shelve.open(pathtomyshelve)
cshelve['object'] = cmymodule
cshelve.close()
this actually perform a shelve. If I run an ipython session within the same import shelve and:
from MyModule import MyModule
import shelve
pathtomyshelve ="/some/path/shelve"
shelve_p = shelve.open(pathtomyshelve)
obj = shelve_p['object']
obj
then I get:
{'object': <MyModule.MyModule object at 0x2139510>}
BUT
When I use my outofshelve.py to retrieve my object, which is basically the same code that I ran from the ipython console, I receive:
Import Error: No module named MyModule
What am I missing here? (complete error below)
File "/home/pierre/.qgis2/python/plugins/sig40/sig40_ZR_dialog.py", line 100, in __init__
self.mymodule = shelve_p['object']
File "/usr/lib/python2.7/shelve.py", line 122, in __getitem__
value = Unpickler(f).load()
File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 454, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError: No module named MyModule
I had he same Problem when i tried to use my own Logwriter.
I found that solution. (But it is python 3. so the code may change a bit)
cDir = os.path.dirname(os.path.abspath("logWriter.py"))
sys.path.append(os.path.dirname(cDir))
import logClasses.logWriter as log
My Folder Structure is like that
logClasses
init.py
logWriter.py
mailClasses
init.py
sendMail.py <-- This uses the logWriter.py
I hope that solution work for you like it did for me

python error when importing from __init__ file

I have a package installed in my site-packages dir. Folder structure looks like this
MyPkg\
__init__.py
LogUtils\
__init__.py
logwrapper.py
Shortcuts\
__init__.py <-----this references LogUtils
somefile.py
When I do help ('modules') I see MyPkg listed. But I get the following error in IDLE:
>>> import MyPkg
>>> from MyPkg import LogUtils
>>> from MyPkg import Shortcuts
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
from MyPkg import Shortcuts
File "C:\Python27\lib\site-packages\MyPkg\Shortcuts\__init__.py", line 1, in <module>
from GoToUrl import go_to_url
File "C:\Python27\lib\site-packages\MyPkg\Shortcuts\GoToUrl.py", line 1, in <module>
from LogUtils import logger, log
ImportError: No module named LogUtils
Why would LogUtils import fine standing alone, but throw an error when being imported via an init file??
Seems to me you are lacking some backslashes
MyPkg\
__init__.py
LogUtils\
__init__.py, \
logwrapper.py
Shortcuts\
__init__.py, \
somefile.py
As you see yourself, you are not importing the same module:
>>> from MyPkg import LogUtils
vs.
from LogUtils import logger, log
The first imports a package called MyPkg.LogUtils, the second imports a package called LogUtils. Whether they exist or not depends on your python paths, but in general, if the first one works, change the second one to
from MyPkg.LogUtils import logger, log

AttributeError: 'module' object has no attribute 'Unpickler'

I am running a program in the SciTE text editor and it gets stuck at the import scipy as sp statement.
import pylab as pl
import numpy as np
import scipy as sp
import scipy.integrate as spi
import scipy.optimize as spo
import numpy.random as nr
import matplotlib.pyplot as plt
print "check"
#parameters to be used
rs=0.14
ra=0.0027
js=-0.033
ja=0.81
Mz=91.0
Tz=2.5
root_s=sp.linspace(20.,140.,200) #plotting sigma_A and sigma_S functions against centre of mass energies from 20GeV to 140 GeV
s=(root_s)**2
.....
.....
and I get this error message:
>pythonw -u "collisions.py"
3.14159265359
1.0
Traceback (most recent call last):
File "collisions.py", line 4, in <module>
import scipy as sp
File "C:\Python27\lib\site-packages\scipy\__init__.py", line 85, in <module>
from numpy import oldnumeric
File "C:\Python27\lib\site-packages\numpy\oldnumeric\__init__.py", line 14, in <module>
from compat import *
File "C:\Python27\lib\site-packages\numpy\oldnumeric\compat.py", line 106, in <module>
class Unpickler(pickle.Unpickler):
AttributeError: 'module' object has no attribute 'Unpickler'
>Exit code: 1
The odd thing is that my code works perfectly fine in the interactive qtconsole. I am new to programming, and I have not encountered such a problem elsewhere in the internet. And why is it that the values pi and 1.0 are returned even though there is no where in my code that is supposed to do that?