so I found this program, "BoxParti" made by user tpvasconcelos and I think it could help me greatly with research. Sadly it uses some packages I have never used before and it's kinda problematic to get it to work for me. I didn't change anything in the code but it doesn't want to work with me. Problem is mainly with tkinter and i'm not really familiar with it. I never used GUI before so it's kinda all tricky to me. At the moment I only want to make the program work and check if it could really be useful for me. I've been trying to make it work by myself but I didn't suceed sadly. It's kinda complex for me since I haven't used python in a while + haven't really ever used GUI with anything. Below I paste the link to download the code. I run it on Python 3.8 or 2.7, on both versions i get same errors. Below the link I paste error logs. I would greatly appreciate any tip that could sort of push me in the right direction because it seems to me I'm very lost
https://github.com/TPVasconcelos/BoxParti
Traceback (most recent call last):
File "BoxParti.py", line 1493, in <module>
app = BoxParti()
File "BoxParti.py", line 53, in __init__
frame = F(container, self)
File "BoxParti.py", line 151, in __init__
self.make_plot(frame)
File "BoxParti.py", line 176, in make_plot
self.canvas.show()
AttributeError: 'FigureCanvasTkAgg' object has no attribute 'show'
This code may work in early versions of Python, e.g. python 3.5. Several things have been deprecated. That means, you have to find correct packages.
For instance, if you uncomment the following the code runs on Python 3.8.
Uncomment: #self.canvas.show() in lines; 177, 610, 646, 692, 817, 1268, 1299, 1371
also uncomment; self.canvas.get_tk_widget()#.grid(row=0, column=1), in lines 179, 819.
But it does not show 2D or 3D anime. This could be because of uncommenting self.canvas.show().
As a result, if you want to run this code, you have to find older versions required libraries. Which I do not suggest.
Instead of that, BoxParti have been expanded to mdsea, you can install mdsea which may work better.
Related
This is my first post here. I'm building a Python window application with PyQt5 that implements interactions with the OpenAI completions endpoint. So far, any code that I've written myself has performed fine, and I was reaching the point where I wanted to start implementing long-term memory for conversational interactions. I started by just running my own chain of prompts for categorizing and writing topical subjects and summaries to text files, but I decided it best to try exploring open source options to see how the programming community is managing things. This led me to LangChain, which seems to have some popular support behind it and already implements many features that I intend.
However, I have not had even the tiniest bit of success with it yet. Even the most simple examples don't perform, regardless of what context I'm implementing it in (within a class, outside a class, in an asynchronous loop, to the console, to my text browsers within the main window, whatever) I always get the same error message.
The simplest possible example:
import os
from langchain.llms import OpenAI
from local import constants #For API key
os.environ["OPENAI_API_KEY"] = constants.OPENAI_API_KEY
davinci = OpenAI(model_name= 'text-davinci-003', verbose=True, temperature=0.6)
text = "Write me a story about a guy who is frustrated with Python."
print("Prompt: " + text)
print(davinci(text))
It capably instantiates the wrapper and prints the prompt to the console, but at any point a command is sent through the wrapper's functions to receive generated text, it encounters this AttributeError.
Here is the traceback:
Traceback (most recent call last):
File "D:\Dropbox\Pycharm Projects\workspace\main.py", line 16, in <module>
print(davinci(text))
File "D:\Dropbox\Pycharm Projects\workspace\venv\lib\site-packages\langchain\llms\base.py", line 255, in __call__
return self.generate([prompt], stop=stop).generations[0][0].text
File "D:\Dropbox\Pycharm Projects\workspace\venv\lib\site-packages\langchain\llms\base.py", line 128, in generate
raise e
File "D:\Dropbox\Pycharm Projects\workspace\venv\lib\site-packages\langchain\llms\base.py", line 125, in generate
output = self._generate(prompts, stop=stop)
File "D:\Dropbox\Pycharm Projects\workspace\venv\lib\site-packages\langchain\llms\openai.py", line 259, in _generate
response = self.completion_with_retry(prompt=_prompts, **params)
File "D:\Dropbox\Pycharm Projects\workspace\venv\lib\site-packages\langchain\llms\openai.py", line 200, in completion_with_retry
retry_decorator = self._create_retry_decorator()
File "D:\Dropbox\Pycharm Projects\workspace\venv\lib\site-packages\langchain\llms\openai.py", line 189, in _create_retry_decorator
retry_if_exception_type(openai.error.Timeout)
AttributeError: module 'openai.error' has no attribute 'Timeout'
I don't expect that there is a fault in the LangChain library, because it seems like nobody else has experienced this problem. I imagine I may have some dependency issue? Or I do notice that others using the LangChain library are doing so in a notebook development environment, and my lack of familiarity in that regard is making me overlook some fundamental expectation of the library's use?
Any advice is welcome! Thanks!
What I tried: I initially just replaced my own function for managing calls to the completion endpoint with one that issued the calls through LangChain's llm wrapper. I expected it to work as easily as my own code had, but I received that error. I then stripped everything apart layer by layer attempting to instantiate the wrapper at every scope of the program, then I attempted to make the calls in an asynchronous function through a loop that waited to completion, and no matter what, I always get that same error message.
I think it might be something about your current installed versions of Python, OpenAI, and/or LangChain. Maybe try using a newer version of Python and OpenAI. I'm new to Python and these things but hopefully I could help.
I am working a somewhat extensive python program that uses multiprocessing. Because I wanted the user to see some progress on the console when running the program, I read about using a shared counter on stackoverflow and after a while of playing around with my code, I got it to work. As I said it's too much code to post here, but the gist is that I instantiate a multiprocessing array after the name==main line,
if __name__ == "__main__":
total_progress_counter = Array('i',[0,0])
and then during the main portion of code I pass this array to a function in other module:
some_name.plot(<other variables>,
total_progress_counter=total_progress_counter)
Then within that other function, I used the .get_lock method that I found described here on stackoverflow:
with total_progress_counter.get_lock():
total_progress_counter[0] += self.total_panels_to_plot
I also update the other component, total_progress_counter[1], in the same function. This works fine for me on my work machine, where I wrote the code, and that machine has a Centos operating system.
But, when I run it on my personal MacBook it gives the following traceback:
Traceback (most recent call last):
File "./program.py", line 775, in <module>
program.run()
File "./program.py", line 177, in run
cases_plotted = pool.map(self.__plot__, all_cases)
File "/opt/anaconda3/lib/python3.8/multiprocessing/pool.py", line 364, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "/opt/anaconda3/lib/python3.8/multiprocessing/pool.py", line 771, in get
raise self._value
AttributeError: 'list' object has no attribute 'get_lock'
I have python3 version 3.8.3 on my personal machine and python3 version 3.7.4 on my work machine. Can anyone help me understand why I'm getting different behavior on these two environments? I'd be grateful, as this is meant to be software others might use on different machines.
I am currently working on a University Project. That's why I am not sure if I can post the code of the project, so I won't (It is pretty huge anyways).
Well, so I spent quite some time installing all the modules to get the program to run. This was a pain at first but with Anaconda I finally got all the modules installed.
Now I get this Error. I am not sure what it means. I looked at line 928 of _pswindows.py but it didn't help me.
I know this project was originally programmed on Linux starting about 2-3 years ago and I am using Windows 10 and Spyder, so maybe there lies the problem? Googling the Error didn't help either...
How could I fix this?
File "ui-test.py", line 20, in
web_ui_thread = WebUIThread(config_fln, user_config_fln, ui_par, debug=True)
File "C:\Users\Flitschi\Documents\TU\BA\WebUI\Sprechhilfe-Python-ui\bionic_voice\webui\server.py", line 125, in init
p.nice(10)
File "C:\ProgramData\Anaconda3\lib\site-packages\psutil__init__.py", line 711, in nice
self._proc.nice_set(value)
File "C:\ProgramData\Anaconda3\lib\site-packages\psutil_pswindows.py", line 635, in wrapper
return fun(self, *args, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\psutil_pswindows.py", line 928, in nice_set
return cext.proc_priority_set(self.pid, value)
OSError: [WinError 87] Falscher Parameter
I have tried running the code found at http://computationallegalstudies.com/2009/11/15/programming-dynamic-models-in-python-3-outbreak-on-a-network/ but at the end the following shows up:
File "/Library/Python/2.7/site-packages/igraph/drawing/__init__.py", line 446, in plot
result = Plot(target, bbox, background=kwds.get("background", "white"))
File "/Library/Python/2.7/site-packages/igraph/drawing/__init__.py", line 117, in __init__
self._surface_was_created = not isinstance(target, cairo.Surface)
File "/Library/Python/2.7/site-packages/igraph/drawing/utils.py", line 396, in __getattr__
raise TypeError("plotting not available")
TypeError: plotting not available
It's a code for modelling SIR model on networks. I really need someone's help as I am not able to use a computer , a mac in this case. Thank you in advance
You need to install the Cairo library and its Python bindings for plotting. If you are using Homebrew, it is simply a matter of brew install cairo py2cairo, assuming that you use the system Python (which you seem to be, judging from the stack trace).
I read in the howto documentation to install Trigger, but when I test in python environment, I get the error below:
>>> from trigger.netdevices import NetDevices
>>> nd = NetDevices()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/trigger/netdevices/__init__.py", line 913, in __init__
with_acls=with_acls)
File "/usr/local/lib/python2.7/dist-packages/trigger/netdevices/__init__.py", line 767, in __init__
production_only=production_only, with_acls=with_acls)
File "/usr/local/lib/python2.7/dist-packages/trigger/netdevices/__init__.py", line 83, in _populate
# device_data = _munge_source_data(data_source=data_source)
File "/usr/local/lib/python2.7/dist-packages/trigger/netdevices/__init__.py", line 73, in _munge_source_data
# return loader.load_metadata(path, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/trigger/netdevices/loader.py", line 163, in load_metadata
raise RuntimeError('No data loaders succeeded. Tried: %r' % tried)
RuntimeError: No data loaders succeeded. Tried: [<trigger.netdevices.loaders.filesystem.XMLLoader object at 0x7f550a1ed350>, <trigger.netdevices.loaders.filesystem.JSONLoader object at 0x7f550a1ed210>, <trigger.netdevices.loaders.filesystem.SQLiteLoader object at 0x7f550a1ed250>, <trigger.netdevices.loaders.filesystem.CSVLoader object at 0x7f550a1ed290>, <trigger.netdevices.loaders.filesystem.RancidLoader object at 0x7f550a1ed550>]
Does anyone have some idea how to fix it?
The NetDevices constructor is apparently trying to find a "metadata source" that isn't there.
Firstly, you need to define the metadata. Second, your code should handle the exception where none is found.
I'm the lead developer of Trigger. Check out the the doc Working with NetDevices. It is probably what you were missing. We've done some work recently to improve the quality of the setup/install docs, and I hope that this is more clear now!
If you want to get started super quickly, you can feed Trigger a CSV-formatted NetDevices file, like so:
test1-abc.net.example.com,juniper
test2-abc.net.example.com,cisco
Just put that in a file, e.g. /tmp/netdevices.csv and then set the NETDEVICES_SOURCE environment variable:
export NETDEVICES_SOURCE=/tmp/netdevices.csv
And then fire up python and continue on with your examples and you should be good to go!
I found that the default of /etc/trigger/netdevices.xml wasn't listed in the setup instructions. It did indicate to copy from the trigger source folder:
cp conf/netdevices.json /etc/trigger/netdevices.json
But, I didn't see how to specify this instead of the default NETDEVICES_SOURCE on the installation page. But, as soon as I had a file that NETDEVICES_SOURCE pointed to in my /etc/trigger folder, it worked.
I recommend this to get the verifying functionality examples to work right away with minimal fuss:
cp conf/netdevices.xml /etc/trigger/netdevices.xml
Using Ubuntu 14.04 with Python 2.7.3