Ask Your Question
1

Problem: Python scripts that previously worked on an Ubuntu 16.04 system do not work on Fedora28 system.

asked 2018-05-31 11:30:05 -0500

leftright gravatar image

I run a script as follows: python3 benchmarks.001.py

I get this error: Traceback (most recent call last): File "benchmarks.001.py", line 32, in <module> import os, sys, json, re, csv, requests, xlsxwriter ModuleNotFoundError: No module named 'xlsxwriter'

I’ve tried running it this way: /usr/bin/python3 benchmarks.001.py

same result: Traceback (most recent call last): File "benchmarks.001.py", line 32, in <module> import os, sys, json, re, csv, requests, xlsxwriter ModuleNotFoundError: No module named 'xlsxwriter'

I’ve installed xlsxwriter using pip install xlsxwriter

Attempting to re-install xlsxwriter gives the following: Requirement already satisfied: xlsxwriter in /usr/lib64/python2.7/site-packages

The scripts I’m trying to run were written for python3. The above statement makes me think perhaps my system is using python2 instead of python3.

So, I ran python -V and got python 2.7.15.

I did some reading here which said how to change the python version globally: https://linuxconfig.org/how-to-switch...

I ran the following: alternatives --list | grep -i python

I got no output which supposedly means no alternative python version is registered.

I then ran the following: alternatives --install /usr/bin/python python /usr/bin/python3.6 2

The above commands supposedly instructs alternatives command to create relevant symbolic links to be used anytime a python command is executed. We have also given python3.6 a higher priority 2 which means, if no python alternative is selected the python3.6 will be used as default. After execution of the above commands your python version should change to python3.6 due to its higher priority. I didn’t add another command which provides python2.7 as an alternative to python3.6.

Then I ran python -V and got python 3.6.5.

I thought this was progress but running a script at this point produces the same missing module error previously described.

If I cd usr/lib64/python2.7/site-packages, I see xlsxwriter in the directory If I cd /usr/lib64/python3.6/site-packages, I do not see xlsxwriter in the directory

Is this perhaps the problem? Is there a specific command for installing xlsxwriter that puts it in the python3 libraries? Or does python3 use some python2 libraries making this observation irrelevant? Have I installed xlsxwriter incorrectly?

I’m not a programmer and I’m new to Fedora. Any suggestions are appreciated.

edit retag flag offensive close merge delete

Comments

That was it. I had to install a couple other modules besides xlsxwriter using your command, then the scripts worked normally. Did any of the commands I executed cause any harm? Is there anything I should undo? THANK YOU. If you submit your comment as an answer, I'll mark it as Answered or whatever the procedure is. Unfortunately, I don't seem to have enough points to upvote you for your most helpful answer.

leftright gravatar imageleftright ( 2018-05-31 14:10:11 -0500 )edit

@leftright Did any of the commands I executed cause any harm? Is there anything I should undo? not absolute not the problem was that there is a difirence between pip and pip3, pip is for python2 and pip3 for python3... regards.,

hhlp gravatar imagehhlp ( 2018-06-01 04:15:00 -0500 )edit

1 Answer

Sort by » oldest newest most voted
4

answered 2018-05-31 12:27:00 -0500

hhlp gravatar image

@leftright have you tried to install via pip3 install --user xlsxwriter and execute your script again...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-05-31 11:30:05 -0500

Seen: 220 times

Last updated: May 31 '18