Re: [Tutor] I need help with my project
Avi and Alan and Sibylle, you're making this a bit hard on the OP (Treyton). Yes he's supplied no context, but it is easy to make some suggestions. Each of yours suggests he design a much wider system (menu entry, web interface, some kind of GUI). All of which is (a) beyond him and (b) irrelevant. Why not pretend he _has_ the existing order, from wherever. Suggest ways to store that order (in a list, or a dict mapping ordable items to counts, or something). Then ask him to write a little Python, or even detailed English prose. Treyton: you seem to have recitied a homework question: If the user selected a sandwich, french fries, and a beverage, reduce the total cost of the order by $1.00. This is what I have to do and I don't know where to start. Ok, this is clear: Treyton can't get off the ground, very common for beginning programmers. The core challenge is to break your problem into a sequence of tasks. How would _you_, a person, do this if you had a food order given to you? Think about a food order. It is usually a list of standard food items, a count of how many of each. And each item will have a cost. The total cost is the sum of (each item's cost * its price * its count), for each item in the order. Or for all possible items, by presuming that unordered items just have a count of 0. So you need: A label for each item, so you can talk about it. You can just use a string for this, eg "sandwich" or "fries". Make the strings simple to start with to avoid spelling mistakes. You can always associate better names with the short strings later. You need a table of items and their costs. It is normal to make a mapping for this, such a Python's dict type. You can write dicts literally: costs = { "sandwich": 200, "fries": 100, } In the example above, I'm imagining you have dollars and cents, and making prices in cents. You also need a representation of the order, being the item type and the count. You could use a Python list for this. Example: [ "fries", 2 ] The whole order might be a list of those, example: [ ["fries", 2 ], [ "sandwich", 3 ] ] So, a list of lists. For purposes of your program you can just set all this stuff up at the beginning, not worrying about GUIs or input forma or any complication. whole_order = [ ["fries", 2 ], [ "sandwich", 3 ] ] Now comes the part you need to do: - write some Python code to compute the total cost of the order (item cost * item count), summed for all the items. Print this raw total so that you can see it is correct. - write some totally separate code to look at the order and decide if the client met your special condition (sandwich, fries, beverage) and get a true/false result. Print this, too. - write a Python statement to subtract $1.00 (or 100 cents) from the total if that condition is true. Print that. Then fiddle the order and run your programme several times to check that it is behaving the way it should. If you find difficulties you cannot surmount, come back here (by replying directly to one of the messages in your discussion) with: - your complete code - your expected output, and the output from your programme - a complete transcript of any error message, for example if your programme raised an exception Make sure these are inline in your message, _not_ attachments. We drop attachments in this list. Cheers, Cameron Simpson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
[Tutor] Moving a conda environment to an off-line computer
Dear colleagues, Soon I'll start to use one of the powerful computers on my university as a tool in my Ph.D. The computer does not have an internet connection and I need to find a way to install a conda environment on it. At first I tried to install and set the conda environment that I need in a computer with internet connection and taking care to copy everything in a path that is similar in the off-line computer (i.e I installed everything on /home/henrique/bin/anaconda3 at home and tried to copy everything to /home/henrique/bin/anaconda3 in the off-line computer - with the same .bashrc) but when I run conda I get an error(it works on my home computer): (deepchem) [henrique@europio qm7] $ python qm7_ANI.py /home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/site-packages/sklearn/ensemble/weight_boosting.py:29: DeprecationWarning: numpy.core.umath_tests is an internal NumPy module and should not be imported. It will be removed in a future NumPy release. from numpy.core.umath_tests import inner1d Traceback (most recent call last): File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/urllib/request.py", line 1318, in do_open encode_chunked=req.has_header('Transfer-encoding')) File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/http/client.py", line 1239, in request self._send_request(method, url, body, headers, encode_chunked) File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/http/client.py", line 1285, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/http/client.py", line 1234, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/http/client.py", line 1026, in _send_output self.send(msg) File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/http/client.py", line 964, in send self.connect() File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/http/client.py", line 936, in connect (self.host,self.port), self.timeout, self.source_address) File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/socket.py", line 704, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/socket.py", line 745, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -2] Name or service not known During handling of the above exception, another exception occurred: Traceback (most recent call last): File "qm7_ANI.py", line 15, in featurizer='BPSymmetryFunction', split='stratified', move_mean=False) File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/site-packages/deepchem/molnet/load_function/qm7_datasets.py", line 50, in load_qm7_from_mat 'http://deepchem.io.s3-website-us-west-1.amazonaws.com/datasets/qm7.mat' File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/site-packages/deepchem/utils/__init__.py", line 85, in download_url urlretrieve(url, os.path.join(dest_dir, name)) File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/urllib/request.py", line 248, in urlretrieve with contextlib.closing(urlopen(url, data)) as fp: File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/urllib/request.py", line 223, in urlopen return opener.open(url, data, timeout) File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/urllib/request.py", line 526, in open response = self._open(req, data) File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/urllib/request.py", line 544, in _open '_open', req) File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/urllib/request.py", line 504, in _call_chain result = func(*args) File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/urllib/request.py", line 1346, in http_open return self.do_open(http.client.HTTPConnection, req) File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/urllib/request.py", line 1320, in do_open raise URLError(err) urllib.error.URLError: Any help is much appreciated -- Henrique C. S. Junior ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Moving a conda environment to an off-line computer
On 30/11/2018 13:47, Henrique Castro wrote: > ... use one of the powerful computers on my university It would help if we knew what kind of powerful computer this is. What OS does it run? It sounds like some variety of Unix, but which? Does it have a C compiler on board? > The computer does not have an internet connection > and I need to find a way to install a conda environment on it. This may be a question that the Anaconda community can better answer since building your own Anaconda suite is non trivial. So unless you find a pre-built environment for your new OS which you can download and copy to removable media you will likely need specialist help. That's more likely to be found on the Anaconda fora than on a general Python list like this one. > File > "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/http/client.py", > line 936, in connect > (self.host,self.port), self.timeout, self.source_address) > File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/socket.py", > line 704, in create_connection > for res in getaddrinfo(host, port, 0, SOCK_STREAM): > File "/home/henrique/bin/anaconda3/envs/deepchem/lib/python3.6/socket.py", > line 745, in getaddrinfo > for res in _socket.getaddrinfo(host, port, family, type, proto, flags): > socket.gaierror: [Errno -2] Name or service not known Apparently the test file tries to access the internet so will obviously fail on a non internet connected device. (BTW is it on any kind of network or is it entirely standalone?) -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Moving a conda environment to an off-line computer
On Fri, Nov 30, 2018 at 01:47:11PM +, Henrique Castro wrote: > Dear colleagues, > Soon I'll start to use one of the powerful computers on my university > as a tool in my Ph.D. The computer does not have an internet > connection and I need to find a way to install a conda environment on > it. [...] Generally speaking, it is *really hard* to copy an installed suite of applications from one machine to another. It's usually best to get an off-line (no internet access) installer, copy it to the machine, then run the installer. This isn't true in all cases, but many application installers make changes to (for example) hidden files, registry settings, environment variables etc and if you miss copying or duplicating even one, the application will not work correctly. For an extremely specialised question like this, you should talk to Conda specialists, or Conda themselves. We know the Python language, we're not experts on the internal details of what it takes for Conda's suite of tools to work. Possibly Conda provides a CD or DVD off-line installer? https://duckduckgo.com/?q=Conda+off-line+installer Another possibility is to build a desktop machine with Conda on-line, install everything you need, then copy that to a virtual machine and copy the VM to the university computer. Talk to the university's system administrator about the possibility of running a VM on the computer. Another possibility is that your installation of Conda is fine, but whatever function you tried using assumes that there is some sort of network connection available, and if it is not available, the function simply fails. If that's the case, you might be stuck: unless Conda fix the bug in the function, it won't work without a network connection. Or perhaps you can talk to the sys admin about turning on the network software on the computer, even if it isn't connected to anything. That might be enough to allow the function to work. (Perhaps it tries to connect to localhost, and if that fails, the whole thing dies.) -- Steve ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Moving a conda environment to an off-line computer
On 11/30/18 5:35 PM, Steven D'Aprano wrote: > On Fri, Nov 30, 2018 at 01:47:11PM +, Henrique Castro wrote: > >> Dear colleagues, > >> Soon I'll start to use one of the powerful computers on my university >> as a tool in my Ph.D. The computer does not have an internet >> connection and I need to find a way to install a conda environment on >> it. > [...] > > Generally speaking, it is *really hard* to copy an installed suite of > applications from one machine to another. It's usually best to get an > off-line (no internet access) installer, copy it to the machine, then > run the installer. You really should poke around the Anaconda community for this. From some earlier research I did when someone asked me a question (not here on tutor), I recall conda used to have some unfortunate dependencies on having an internet connection, and they've done quite a lot of work on making what you want possible. I think there are minimum versions you need, and some flags you need (some kind of --offline thing) but those folks know about this scenario. I have no idea how you do the "install", so I'll just stop writing now... ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Search error code in a logfile and print all lines until the error code
On Thu, Nov 29, 2018 at 06:23:42PM +0530, Asad wrote: [...] > It gives me error : > > IOPub data rate exceeded. > The notebook server will temporarily stop sending output > to the client in order to avoid crashing it. > To change this limit, set the config variable > `--NotebookApp.iopub_data_rate_limit`. > > Current values: > NotebookApp.iopub_data_rate_limit=100.0 (bytes/sec) > NotebookApp.rate_limit_window=3.0 (secs) That doesn't look like a Python error. What is "it" that gives you that error? What precisely are you doing that gives the error? -- Steve ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor