Openopt - DerApproximator package not found - python

While trying to solve a Non Linear Problem in Python using Openopt's NLP.solve() I get this error, summarized as
you should have DerApproximator installed.
I tried
pip install derapproximator
but it says "requirement already satisfied".
I am using Windows 7 x64, Python 3.4 with OpenOpt 0.5604. How do I install this package?
Here is the complete text from the command window.
solution = problem.solve('ralg')
File "C:\Python34\lib\site-packages\openopt-0.5604-py3.4.egg\openopt\kernel\baseProblem.py", line 253, in solve
return runProbSolver(self, *args, **kwargs)
File "C:\Python34\lib\site-packages\openopt-0.5604-py3.4.egg\openopt\kernel\runProbSolver.py", line 292, in runProbSolver solver(p)
File "C:\Python34\lib\site-packages\openopt-0.5604-py3.4.egg\openopt\solvers\UkrOpt\ralg_oo.py", line 159, in __solver__
g = bestPoint._getDirection(self.approach)
File "C:\Python34\lib\site-packages\openopt-0.5604-py3.4.egg\openopt\kernel\Point.py", line 640, in _getDirection
self.direction = self.sum_of_all_active_constraints_gradient()
File "C:\Python34\lib\site-packages\openopt-0.5604-py3.4.egg\openopt\kernel\Point.py", line 565, in sum_of_all_active_constraints_gradient
tmp = p.dc(x, ind)
File "C:\Python34\lib\site-packages\openopt-0.5604-py3.4.egg\openopt\kernel\baseProblem.py", line 550, in <lambda>
self.wrapped_1st_derivatives(x, ind, funcType, ignorePrev, useSparse))
File "C:\Python34\lib\site-packages\openopt-0.5604-py3.4.egg\openopt\kernel\nonLinFuncs.py", line 383, in wrapped_1st_derivatives
derivatives = p.wrapped_func(x, ind, funcType, True, True)
File "C:\Python34\lib\site-packages\openopt-0.5604-py3.4.egg\openopt\kernel\nonLinFuncs.py", line 28, in wrapped_func
p.err('For the problem you should have DerApproximator installed, see http://openopt.org/DerApproximator')
File "C:\Python34\lib\site-packages\openopt-0.5604-py3.4.egg\openopt\kernel\oologfcn.py", line 16, in ooerr
raise OpenOptException(msg)
oologfcn.OpenOptException: For the problem you should have DerApproximator installed, see http://openopt.org/DerApproximator
Update 1
I saw a file named derapproximator-0.52-py3.4.egg in the Python34\Lib\site-packages the path which I had to add as PYTHONPATH key in the Environment variables for openopt to be found by python. I did not know how a file with .egg extension could be used there so I extracted the contents to derapproximator-0.52-py3.4. Whose folder hierarchy on cmd tree looks like
+---derapproximator-0.52-py3.4
| +---DerApproximator
| | \---__pycache__
| \---EGG-INFO
but the error is still the same,
>>> import derapproximator
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'derapproximator'
Then again I tried with renaming the folder to derapproximator-0.52-py3.4.egg but it still doesn't work.

Related

ValueError: Incompatible Language version 11. Must be between 13 and 14

tried to run docly to auto generate some comments for my python code. installation went smooth:
pip install -U PyYAML
pip install docly
however, when trying to process the first file via:
docly-gen first_file.py
there keeps coming the error
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/bin/docly-gen", line 11, in <module>
load_entry_point('docly==0.3.0', 'console_scripts', 'docly-gen')()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/docly/cli/docly_gen.py", line 237, in main
table_rows, docstr_loc, ipynb_files = _process(args, model, tokenizer, ts_lib_path, config)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/halo/halo.py", line 132, in wrapped
return f(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/docly/cli/docly_gen.py", line 154, in _process
for code_tokens, params, start_index, function_name, ds in process_file(f_path, ts_lib_path, args.use_old_model):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/docly/ioutils/__init__.py", line 125, in process_file
result, parser_obj = py_parser.parse(file_path, ts_lib_path)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/docly/parser/parser.py", line 11, in parse
python_parser = PythonParser(library_loc=tslib_path)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tree_hugger/core/parser/python/python_parser.py", line 35, in __init__
super(PythonParser, self).__init__('python', 'python_queries', PythonParser.QUERY_FILE_PATH, library_loc)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tree_hugger/core/code_parser.py", line 41, in __init__
self.parser.set_language(self.language)
ValueError: Incompatible Language version 11. Must be between 13 and 14
already tried playing around with different versions of tree-sitter
anyone has an idea for a fix?
thanks. much appreciated.

Python KeyError: 'flags', when running BlueBorne script

I am trying to run the file l2cap_infra.py with Python 2, but I am getting the following error:
Traceback (most recent call last):
File "l2cap_infra.py", line 524, in <module>
main(*sys.argv[1:])
File "l2cap_infra.py", line 508, in main
l2cap_loop, _ = create_l2cap_connection(src_hci, dst_bdaddr, pcap_path=pcap_path)
File "l2cap_infra.py", line 489, in create_l2cap_connection
handle_information_negotiation_process(l2cap_loop)
File "l2cap_infra.py", line 425, in handle_information_negotiation_process
l2cap_loop.send(info_req)
File "l2cap_infra.py", line 142, in send
self._sock.send(packet)
File "l2cap_infra.py", line 213, in send
self.send_fragment(Raw(str(l2cap)[i:i+L2CAP_DEFAULT_MTU]), i == 0)
File "l2cap_infra.py", line 223, in send_fragment
hci = HCI_Hdr() / HCI_ACL_Hdr(handle=scapy_handle, flags=scapy_flags) / frag
File "/usr/local/lib/python2.7/dist-packages/scapy/base_classes.py", line 227, in __call__
i.__init__(*args, **kargs)
File "/usr/local/lib/python2.7/dist-packages/scapy/packet.py", line 135, in __init__
self.fields[f] = self.get_field(f).any2i(self, v)
File "/usr/local/lib/python2.7/dist-packages/scapy/packet.py", line 170, in get_field
return self.fieldtype[fld]
KeyError: 'flags'
This might be a version conflict; I had a similar problem and I had to edit a file in /usr/local/lib/python2.7/.
What code do I have to change in that linked file or in one of my pip libraries to make this code work?
It seems it's a compatibility issue between BlueBorne and Scapy.
You (most likely) have installed the latest Scapy version (v2.4.0), which dropped the fields kwarg from scapy.layers.bluetooth.HCI_ACL_Hdr's initializer, while BlueBorne (l2cap_infra.py, and possibly others) was not updated (or branched) accordingly.
The latest version that still has it is v2.3.3 ([GitHub]: secdev/scapy - (v2.3.3) scapy/scapy/layers/bluetooth.py).
Possible solutions:
Uninstall your current Scapy version (pip uninstall scapy) and install v2.3.3 (pip install scapy==2.3.3). Probably, this is the simplest (and most suitable) for you ([PyPI]: scapy 2.3.3)
Submit a bug to BlueBorne and wait for them to add support for newer Scapy versions
Fix it yourself ("fields" (v2.3.3) to "PB" + "BC" (v2.4.0) kwargs conversion), and maybe submit a patch :)

Pychecker index error on first run

I've just installed pychecker on windows 7 Pro using "python setup.py install". When I run it on my script using the command:
c:\Python26\Scripts\pychecker -#100 finaltest17.py
I get the following error/traceback:
C:\Users\....\ToBeReleased>C:\Python26\python.exe C:\Python26\Lib\site-packages\pychecker\checker.py -#100 finaltest17.py
Processing module finaltest17 (finaltest17.py)...
Caught exception importing module finaltest17:
File "C:\Python26\Lib\site-packages\pychecker\pcmodules.py", line 533, in setupMainCode()
self.moduleName, self.moduleDir)
File "C:\Python26\Lib\site-packages\pychecker\pychecker\utils.py", line 184, in findModule()
handle, filename, smt = _q_find_module(p, path)
File "C:\Python26\Lib\site-packages\pychecker\pychecker\utils.py", line 162, in _q_find_module()
if not cfg().quixote:
File "C:\Python26\Lib\site-packages\pychecker\pychecker\utils.py", line 39, in cfg()
return _cfg[-1]
IndexError: list index out of range
Traceback (most recent call last):
File "C:\Python26\Lib\site-packages\pychecker\checker.py", line 364, in <module>
sys.exit(main(sys.argv))
File "C:\Python26\Lib\site-packages\pychecker\checker.py", line 337, in main
importWarnings = processFiles(files, _cfg, _print_processing)
File "C:\Python26\Lib\site-packages\pychecker\checker.py", line 270, in processFiles
loaded = pcmodule.load()
File "C:\Python26\Lib\site-packages\pychecker\pcmodules.py", line 477, in load
return utils.cfg().ignoreImportErrors
File "C:\Python26\Lib\site-packages\pychecker\pychecker\utils.py", line 39, in cfg
return _cfg[-1]
IndexError: list index out of range
If anyone could point me in the right direction that would be great.
Thanks
Stewart
Problem resolved.
I found the following support request on SourceForge which refers to a need to use short format (8.3) path and filenames in pychecker.bat and not long format as is allowed in newer versions of Windows.
https://sourceforge.net/p/pychecker/support-requests/7/#96cb

python install dependencies to project

I want to make an application for Sailfish OS using QML and Python. I want to have models in python and save data to sqlite using SQLAlchemy. Problem is I have no idea how can I get dependencies to my project and Sailfish OS does not have SQLAlchemy in repository. I tryed to install it using pip to lib directory in my project using
pip install --install-option="--install-purelib=pwd/lib" sqlalchemy
It installed SQLAlechemy as i expected, but when i tryed to run my project, it crashed on select with where condition - but the same code worked fine when I imported SQLAlchemy from my system.
I both installed SQLAlchemy are 1.0.8 version.
Select, which works with my SQLAlchemy installed without prefix
def getValue(self, key):
s = select([self.table.c.value]).where(self.table.c.key==key)
return self.con.execute(s).fetchone()
and error
Traceback (most recent call last):
File "", line 1, in
File "/home/tobik/Buhvico/Programovani/beardware/hgclient/qml/hgo/models.py", line 58, in getValue
s = select([self.table.c.value]).where(self.table.c.key==key)
File "", line 2, in where
File "/home/tobik/Buhvico/Programovani/beardware/hgclient/qml/hgo/lib/sqlalchemy/sql/base.py", line 45, in _generative
fn(self, *args[1:], **kw)
File "/home/tobik/Buhvico/Programovani/beardware/hgclient/qml/hgo/lib/sqlalchemy/sql/selectable.py", line 2897, in where
self.append_whereclause(whereclause)
File "/home/tobik/Buhvico/Programovani/beardware/hgclient/qml/hgo/lib/sqlalchemy/sql/selectable.py", line 3122, in append_whereclause
True_._ifnone(self.whereclause), whereclause)
File "/home/tobik/Buhvico/Programovani/beardware/hgclient/qml/hgo/lib/sqlalchemy/sql/elements.py", line 1929, in and
return cls.construct(operators.and, True_, False_, *clauses)
File "/home/tobik/Buhvico/Programovani/beardware/hgclient/qml/hgo/lib/sqlalchemy/sql/elements.py", line 1863, in _construct
util.coerce_generator_arg(clauses)
File "/home/tobik/Buhvico/Programovani/beardware/hgclient/qml/hgo/lib/sqlalchemy/sql/elements.py", line 1862, in
for clause in
File "/home/tobik/Buhvico/Programovani/beardware/hgclient/qml/hgo/lib/sqlalchemy/sql/elements.py", line 3766, in _expression_literal_as_text
return _literal_as_text(element, warn=True)
File "/home/tobik/Buhvico/Programovani/beardware/hgclient/qml/hgo/lib/sqlalchemy/sql/elements.py", line 3787, in _literal_as_text
"instead" % type(element)
hgo.lib.sqlalchemy.exc.ArgumentError: SQL expression object or string expected, got object of type instead
Thanks for ur suggestions :)

Buildout error on custom mfabrik gomobiletheme

If i create a new theme, i become a Traceback:
../bin/paster create -t gomobile_theme gomobiletheme.mytheme
...
Traceback (most recent call last):
File "../bin/paster", line 275, in <module>
paste.script.command.run()
File "/opt/plone4/plone4/eggs/PasteScript-1.7.5-py2.6.egg/paste/script/command.py", line 104, in run
invoke(command, command_name, options, args[1:])
File "/opt/plone4/plone4/eggs/PasteScript-1.7.5-py2.6.egg/paste/script/command.py", line 143, in invoke
exit_code = runner.run(args)
File "/opt/plone4/plone4/eggs/PasteScript-1.7.5-py2.6.egg/paste/script/command.py", line 238, in run
result = self.command()
File "/opt/plone4/plone4/eggs/PasteScript-1.7.5-py2.6.egg/paste/script/create_distro.py", line 170, in command
egg_info_dir = pluginlib.egg_info_dir(output_dir, dist_name)
File "/opt/plone4/plone4/eggs/PasteScript-1.7.5-py2.6.egg/paste/script/pluginlib.py", line 135, in egg_info_dir
% ', '.join(all))
IOError: No egg-info directory found (looked in ./gomobiletheme.mytheme/./gomobiletheme.mytheme.egg-info, ./gomobiletheme.mytheme/setup.cfg/gomobiletheme.mytheme.egg-info, ./gomobiletheme.mytheme/docs/gomobiletheme.mytheme.egg-info, ./gomobiletheme.mytheme/README.txt/gomobiletheme.mytheme.egg-info, ./gomobiletheme.mytheme/gomobiletheme/gomobiletheme.mytheme.egg-info, ./gomobiletheme.mytheme/src/gomobiletheme.mytheme.egg-info, ./gomobiletheme.mytheme/setup.py/gomobiletheme.mytheme.egg-info, ./gomobiletheme.mytheme/CONTRIBUTORS.txt/gomobiletheme.mytheme.egg-info, ./gomobiletheme.mytheme/CHANGES.txt/gomobiletheme.mytheme.egg-info)
Then I added my theme to buildout.cfg, reran it become a error like this:
bin/buildout
Develop: '/opt/plone4/plone4/src/gomobiletheme.mytheme'
error in gomobiletheme.mytheme setup command: Distribution
contains no modules or packages for namespace package 'gomobiletheme'
While:
Installing.
Processing develop directory '/opt/plone4/plone4/src/
gomobiletheme.mytheme'.
An internal error occured due to a bug in either zc.buildout or in a
recipe being used:
Traceback (most recent call last):
File "/opt/plone4/plone4/eggs/zc.buildout-1.4.3-py2.6.egg/zc/
buildout/buildout.py", line 1660, in main
getattr(buildout, command)(args)
File "/opt/plone4/plone4/eggs/zc.buildout-1.4.3-py2.6.egg/zc/
buildout/buildout.py", line 394, in install
installed_develop_eggs = self._develop()
File "/opt/plone4/plone4/eggs/zc.buildout-1.4.3-py2.6.egg/zc/
buildout/buildout.py", line 634, in _develop
zc.buildout.easy_install.develop(setup, dest)
File "/opt/plone4/plone4/eggs/zc.buildout-1.4.3-py2.6.egg/zc/
buildout/easy_install.py", line 895, in develop
*args) == 0
AssertionError
Know anyone whats wrong?
I think this is caused by the template you are using. Perhaps it is outdated.
Check if your setup.py looks like this:
packages=find_packages('src'),
namespace_packages=['gomobiletheme'],
But you need an additional:
package_dir = {'': 'src'},
directive to get the buildout working again.

Categories

Resources