question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

savetxt() errors with python3

See original GitHub issue

Here’s the error message. Should be easy to fix.

In [10]: sol.savetxt()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-fff6eb73d01a> in <module>
----> 1 sol.savetxt()

c:\users\berk\dropbox (mit)\mit graduate school\code\gpkit\gpkit\solution_array.py in savetxt(self, filename, printmodel, **kwargs)
    508         with open(filename, "w") as f:
    509             if printmodel and self.model:
--> 510                 f.write(str(self.model).encode("utf-8"))
    511             f.write(self.table(**kwargs).encode("utf-8"))
    512

TypeError: write() argument must be str, not bytes

Since GPkit claims to be python2/3 compatible, we should perhaps consider running tests for both versions to avoid future issues.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
bqpdcommented, Aug 27, 2019

(weekly ping)

0reactions
bqpdcommented, Sep 7, 2019

Let’s try and debug this on your computer early next week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

numpy.savetxt resulting a formatting mismatch error in ...
When I'm stepping into the savetxt code, the print the error (traceback.format_exc()) in the catch block (numpy.lib.npyio, line 1158), the error is ...
Read more >
numpy.savetxt cannot save file correctly using file handle
I can save the array to a "foo.txt" file as below: np.savetxt('foo.txt', points, fmt='%f %f %f %d %d %d') but if I run...
Read more >
numpy.savetxt — NumPy v1.24 Manual
Save an array to a text file. Parameters: fnamefilename or file handle. If the filename ends in .gz , the file ...
Read more >
Python NumPy Savetxt + Examples
To save a numpy array to a text file we can easily use the numpy.savetxt() method. In Python, this method is available in...
Read more >
How to load and save 3D Numpy array to file using savetxt ...
Numpy.savetxt() is a method in python in numpy library to save an 1D and 2D array to a file. Syntax: numpy.savetxt ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found