I fail to install a usable version of zopeskel in my Plone site, both in my Debian-based Linux box and on the CentOS-based server.
In my buildout.cfg I have, following this how-to:
[zopeskel]
recipe = zc.recipe.egg
unzip = true
eggs =
ZopeSkel <= 3.0dev
Paste
PasteDeploy
PasteScript
# ${buildout:eggs}
(I don't have Dexterity contents nor diazothemes for now, so I tried without the zopeskel.dexterity and zopeskel.diazotheme, but it doesn't seem to make a difference; same result when I add them). My [buildout] section doesn't contain eggs, so I needed to comment out this as well.
After building I tried
$ bin/zopeskel --list
Traceback (most recent call last):
File "bin/zopeskel", line 15, in <module>
import zopeskel.zopeskel_script
File ".../eggs/ZopeSkel-2.21.2-py2.7.egg/zopeskel/__init__.py", line 2, in <module>
from zopeskel.basic_namespace import BasicNamespace
File ".../eggs/ZopeSkel-2.21.2-py2.7.egg/zopeskel/basic_namespace.py", line 2, in <module>
from zopeskel.vars import var, DottedVar, StringVar, BooleanVar, TextVar
File ".../eggs/ZopeSkel-2.21.2-py2.7.egg/zopeskel/vars.py", line 2, in <module>
from paste.script.templates import var as base_var
File ".../eggs/PasteScript-2.0.2-py2.7.egg/paste/script/templates.py", line 7, in <module>
from . import copydir
File ".../eggs/PasteScript-2.0.2-py2.7.egg/paste/script/copydir.py", line 6, in <module>
from six.moves.urllib.parse import quote
ImportError: No module named urllib.parse
$ grep six bin/zopeskel
'.../eggs/six-1.2.0-py2.7.egg',
This is a quite old version (pip install six gave me 1.9.0), and it doesn't contain anything like quote or urllib.parse.
I assume some involved package fails to specify a needed version; but adding something like six >= 1.3 didn't even build.
How can I fix this? Thank you!
I guess the 1.2.0 version of the six package is specified by one of the extends of your buildout.
You could use buildout annotate to find which one it is.
You need to add a versions section:
[versions]
six = 1.9.0
Let it fail!
Seriously, ditch zopeskel for mrbob and this template....
zopeskel/paster are now seen as unmaintainable in the long run (due to dependencies that are not been worked on at all. mrbob has no major dependencies and is the approach that Plone 5 universal installer is taking instead of zopeskel.
But to make it more practical: zopeskel & it's plugins give issues like your one pretty regularly, mrbob does not in my experience. Because it is maintained it will also produce more up to date "model code" than zopeskel will.
Admittedly, mrbob doesn't (yet) have the number of plugins that zopeskel does, but since archetypes has been overtaken by dexterity, there is less heavy "boilerplate code" to generate. It's your choice, but if you are starting Plone now - then just learn one of mrbob or zopeskel (There's enough other stuff to learn).
Install it like this (obviously you have to add mrbob to your parts list too)
[mrbob]
recipe = zc.recipe.egg:scripts
eggs =
mr.bob
bobtemplates.plone
Related
I am refactoring code from python2(RHEL 7.6) to python3(RHEL 8.2) and I have problem with missing library in python3.6.
Problem:
from rpmUtils.miscutils import splitFilename ModuleNotFoundError: No module named 'rpmUtils'
I've tried to install python3-dnf and python3-rpm packages to RHEL8, but still not working. Is there any solution how to use this library in python3.6 and RHEL8 or should I write some custom function by myself?
Thank you for your answer.
This library was indeed removed, but you have several other options you can use.
Please note that these other functions expect to receive a string in the NEVRA (name, epoch, version, release, architecture) format as an input, not a filename. Thus you must remove the '.rpm' extension of the filename, in order to get a NVRA string (epoch normally is not included in the filename of the RPM package).
So basically you have 2 options:
to use dnf as suggested in i.e. https://bugzilla.redhat.com/show_bug.cgi?id=1364504
to use hawkey i.e. :
import hawkey
rpm_base_filename = os.path.basename(rpm_file)
nevra = hawkey.split_nevra(rpm_base_filename[:-len(".rpm")])
name = nevra.name
version = nevra.version
release = str(nevra.release)
epoch = str(nevra.epoch)
arch = nevra.arch
For example here is a patch for such modification that I made for one of the tools we use as part of the oVirt release process:
https://github.com/oVirt/releng-tools/commit/823405e6b261f7ff27ddbba0e8fa2b86dd2a8698
I am trying an MXNet tutorial mentioned at http://mxnet.io/tutorials/embedded/wine_detector.html (Section "Running the Model" on a raspberry pi3 using python3.4, specifically the script "inception_predict.py". I managed to fix a couple of issue but am getting stumped at this error:
>> import inception_predict
[23:43:37] src/nnvm/legacy_json_util.cc:190: Loading symbol saved by previous version v0.8.0. Attempting to upgrade...
[23:43:37] src/nnvm/legacy_json_util.cc:198: Symbol successfully upgraded!
>> predict_from_url("http://imgur.com/HzafyBA")
Traceback (most recent call last):
File "", line 1, in
NameError: name 'predict_from_url' is not defined
Function predict_from_url is defined in the imported file inception_predict.py (as mentioned in the tutorial) so why is python telling me it is not defined?
What am I doing wrong?
The tutorial has a few errors that you need to fix to make it run:
add time to the import list in the inception_predict.py
...
import cv2, os, urllib, time
...
use a URL that you can actually download directly (use your favorite image search engine to find ones)
call the full name function
inception_predict. predict_from_url("https://media.mnn.com/assets/images/2017/01/cow-in-pasture.jpg.838x0_q80.jpg")
After these small changes you will see something like this:
pre-processed image in 0.27312707901
MKL Build:20170209
forward pass in 0.131096124649
probability=0.784963, class=n02403003 ox
probability=0.099463, class=n03868242 oxcart
probability=0.035585, class=n03967562 plow, plough
probability=0.033620, class=n02415577 bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis
probability=0.015443, class=n02412080 ram, tup
[(0.78496253, 'n02403003 ox'), (0.09946309, 'n03868242 oxcart'), (0.035584591, 'n03967562 plow, plough'), (0.033620458, 'n02415577 bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis'), (0.015442736, 'n02412080 ram, tup')]
I am on a Mac with OS 10.11.6, and I'm learning the notebook interface for Sage 7.2. As a start, in a Sage worksheet I created a .txt file containing the string [1, 2, 3] and saved it. I can open the text file directly and verify its contents just by clicking on it, but I can't yet do this in Sage.
I'd like to be able to open it and convert the string to a usable Sage object. I'd appreciate explicit instructions, assuming nothing at all about my Sage background. Thank you.
Note: The procedure to do what I just asked in the Sage documentation under "Saving and Loading Individual Objects" doesn't work in my environment (specs above.) I do A = [1, 2, 3]. Then I do save(A, 'A') and Sage returns a hot link for A.sobj. Then I hit the save-and-quit button. Then I hit "sign out." Then I sign back in and go to the worksheet where I did the steps I just described. I do A = load('A'). This is what Sage says:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_3.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("QSA9IGxvYWQoJ0EnKQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/private/var/folders/7n/t9k4hfyn44s2qp7wxt479kn80000gn/T/tmpEa1OkK/___code___.py", line 2, in <module>
exec compile(u"A = load('A')" + '\n', '', 'single')
File "", line 1, in <module>
File "sage/structure/sage_object.pyx", line 1032, in sage.structure.sage_object.load (build/cythonized/sage/structure/sage_object.c:11594)
IOError: [Errno 2] No such file or directory: 'A.sobj'`
I found an answer in Finch's book. First a quote:
“We used a module called os from the Python standard library module to help us write code that can run on multiple platforms. A text file must have a special character to denote the end of each line in the file. Unfortunately, for historical reasons, each family of operating systems (Mac, Windows, and UNIX) uses a different end-of-line character. The os module has a constant called linesep that contains the correct character for the platform that the code is run on. We used the statement import os to make the module available, and accessed the constant using the syntax os.linesep. We also used the function os.path.join to join the path to the file name with the correct character for the current operating system.”
Excerpt From: Craig Finch. “Sage Beginner's Guide.”
Example using a file named "File2.txt" containing a single text character, '1':
import os path='/Users/barrybrent/.sage/sage_notebook.sagenb/home/store/2/21/212/2123/admin/19/data/' fileName='File2.txt' times = [] text_file = open(os.path.join(path, fileName), 'r') line = text_file.readline()
(Comment: is just a character string. To convert it a Sage object useful in computations:)
elements=line.split(',') times.append(float(elements[0].strip()))
(Comment: evaluate:)
times[0]
(Comment: Sage says"1.0". Now can we do arithmetic with times[0]?)
times[0]+1
Sage says "2.0"
We need to (re)generated third party packages on EL7 but we don't want to change SPEC file as suggested (%define debug_package %{nil} https://www.redhat.com/archives/shrike-list/2003-April/msg00069.html) and neither changing the ~/.rpmmacros file as it is on a shared box for RPM build.
Is there any way to solve this via command line (additional parameter) with rpmbuild?
After many tests I found the solution. In fact, it is possible to define debug_package outside of the SPEC file, using --define. Which gives:
rpmbuild --define "debug_package %{nil}" -ba SPECS/original.spec
Result is: I don't modify the third party SPEC file and no RPM -debuginfo is generated.
rpmbuild --rebuild --nodebuginfo file.src.rpm -- this still generates debuginfo rpms
Another solution:
cat /etc/rpm/macros
%debug_package %{nil}
enter code here
# -*- coding: utf-8 -*-
import math
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig1=plt.figure()
ax=plt.axes(xlim=(-10,10), ylim=(-10,10))
line,=ax.plot([],[],lw=1)
"""def init ():
line.set_data([],[])
return line,"""
dt=0.001
X=[]
Y=[]
r=float(input("Enter the radius :: "))
w=float(input("Enter angular frequency :: "))
def run(data):
t=0
while w*t<=2*math.pi:
x=r*math.cos(w*t)
y=r*math.sin(w*t)
X.append(x)
Y.append(y)
t=t+dt
line.set_data(X,Y)
return line,
line,=ax.plot(X,Y,lw=2)
FFMpegWriter = animation.writers['ffmpeg']
writer = FFMpegWriter(fps=15, metadata=dict(artist='Me'), bitrate=1800)
anim=animation.FuncAnimation(fig1,run,frames=200,interval=20,blit=True)
anim.save('amim.mp4',writer=writer)
The error message shown is ::
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/tathagata/anaconda3/lib/python3.4/site- packages/spyderlib/widgets/externalshell/sitecustomize.py", line 685, in runfile
execfile(filename, namespace)
File "/home/tathagata/anaconda3/lib/python3.4/site- packages/spyderlib/widgets/externalshell/sitecustomize.py", line 85, in execfile
exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)
File "/home/tathagata/Documents/Python scripts/circleamim.py", line 35, in <module>
FFMpegWriter = animation.writers['ffmpeg']
File "/home/tathagata/anaconda3/lib/python3.4/site-packages/matplotlib/animation.py", line 81, in __getitem__
return self.avail[name]
KeyError: 'ffmpeg'
I use anacoda distribution and SPYDER as my IDE. I have seen the many solutions related to key errors. But the movie wont run. How can I make the movie to run? I hope there are no other logical errors.
First install ffmpeg and add path to ffmpeg
# on windows
plt.rcParams['animation.ffmpeg_path'] = 'C:\\ffmpeg\\bin\\ffmpeg.exe'
# on linux
plt.rcParams['animation.ffmpeg_path'] = u'/home/username/anaconda/envs/env_name/bin/ffmpeg'
Note for linux users: The path for ffmpeg can be found by simply using which: which ffmpeg
Also instead of
FFMpegWriter = animation.writers['ffmpeg']
writer = FFMpegWriter(fps=15, metadata=dict(artist='Me'), bitrate=1800)
I just used writer = animation.FFMpegWriter()
It seems that ffmpegis not installed on your system. Try the following code:
import matplotlib.animation as animation
print(animation.writers.list())
It will print out a list of all available MovieWriters. If ffmpegis not among it, you need to install it first from the ffmpeg homepage.
If you have Homebrew, literally just run the command
brew install ffmpeg
And Homebrew will take care of the rest (dependencies, etc). If you don't, I would recommend getting Homebrew or something like it (apt-get on Linux is built in, or an alternative on OS X would be Macports)
I have also posed with same problem(keyError: 'ffmpeg') but instead of using anakonda, I used IDLE3. So, first i checked for 'ffmpeg' in terminal it wasn't installed so installed it.
Using: sudo apt install ffmpeg
and when I run my save_animation program, it worked generating animation files in '.mpeg' format.