ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I try write code to export data base to Excel file.
Ageing I have a problem with modules.
I try find how install that and still don't works.
Please help, thanks.
# beginning of code
import pandas as pd
import openpyxl
# welcome
print("That is simple data base.")
print("Please input date.")
print('\n')
Hi.
[CODE]I try write code to export data base to Excel file. Ageing I have a problem with modules. I try find how install that and still don't works. Please help, thanks.
Code:
# beginning of code
import pandas as pd
import openpyxl
# welcome
print("That is simple data base.")
print("Please input date.")
print('\n')
# input data
username = input("Name: ")
usersurename = input("Surename: ")
age = input("Enter age: ")
height = input("Enter height: ")
yob = input("Enter YoB: ")
# open file
f = open("data_base.txt", "a")
# write date to file
f.write('\n')
f.write("Name: ")
f.write(username)
f.write('\n')
f.write("Surename: ")
f.write(usersurename)
f.write('\n')
f.write("Age: ")
f.write(age)
f.write('\n')
f.write("height: ")
f.write(height)
f.write('\n')
f.write("yob: ")
f.write(yob)
f.write('\n')
f.write('\n')
# close file
f.close()
# open file data base and print data
f = open("data_base.txt", "r")
print(f.read())
# export to excel
df = pd.DataFrame([[username, usersurename, age, height, yob], [12, 22, 32], [31, 32, 33]],
index=['Name', 'Surnename', 'Age', 'height', 'yob'], columns=['a', 'b', 'c'])
print(df)
# end export to excel
# end of code
Python 3.11.0rc1 (main, Aug 12 2022, 10:02:14) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license()" for more information.
======== RESTART: /home/piotr/python/data_base/02_data_base_export_to_excel.py ========
Traceback (most recent call last):
File "/usr/lib/python3.11/idlelib/run.py", line 578, in runcode
exec(code, self.locals)
File "/home/piotr/python/data_base/02_data_base_export_to_excel.py", line 3, in <module>
import pandas as pd
File "/usr/lib/python3/dist-packages/pandas/__init__.py", line 22, in <module>
raise ImportError(
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troub...porterror.html
Please note and check the following:
* The Python version is: Python3.11 from "/usr/bin/python3.11"
* The NumPy version is: "1.21.5"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
Bolded a part in your code (and you need to use CODE tags when posting code, to make it easier to read). Did you read that link, and check the things advised?? You don't tell us what version/distro of Linux you're using, or how you installed numpy, or gave us any details. Just posting your code with a VERY well explained error doesn't tell us much.
Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license()" for more information.
Is this supposed to tell us something??? You had a very clear error, with instructions on how to fix it, and were asked several questions...none of which you answered. If you're not going to answer the questions asked, there isn't going to be anything we can help you with.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.