python can not import docx - python

I will state that my goal was simply to write to a docx file for the following reasons:
I am building a study guide and I thought have a little automation to do so in the labeling process would be easier
I like to challenge myself to make my code work
I have tried:
pip install python-docx
pip install docx
pip uninstall python-docx
pip uninstall docx
pip3 install python-docx
pip3 install docx
Though I am still getting a ModuleNotFoundError error message, could anyone think of what to try next?
Traceback (most recent call last):
File "c:\users\xxx\onedrive\desktop\my programs\having fun.py", line 2, in
import docx
ModuleNotFoundError: No module named 'docx'

Related

How to fix Python import google API error

from googleapiclient.discovery import build
After pip installing google api for python google tells me to use this command however the command doesn't work!
Can anyone help?
https://developers.google.com/docs/api/quickstart/python
Traceback (most recent call last):
File "C:\Users\M1\PycharmProjects\YouTube\main.py", line 1, in <module>
from googleapiclient.discovery import build
ModuleNotFoundError: No module named 'googleapiclient'
https://developers.google.com/docs/api/quickstart/python
I have installed the libraries using the following command:
pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
Then, you can check that the library has been installed properly by running:
pip show google-api-python-client
Now, you should be able to import the libraries in your python code. Make sure that the code is executed within your virtual environment in case you are using one.

Why cant I import/use installed libraries in Python

I recently downloaded Python 3.10 because I used 3.9. At first, everything worked fine. Sadly, I can't use installed libraries nor use newly downloaded ones, since I deleted Python 3.9. What can I do about this problem?
VSCode gives me this Error message:
Traceback (most recent call last):
File "e:\XXXX\XXXX.py", line 5, in <module>
from playsound import playsound
ModuleNotFoundError: No module named 'playsound'
You can check installed packages using this command:
pip freeze
or
pip list
Uninstall and install using command pip install <package-name>

importing openbabel wrapper pybel for macos without conda

Previously I asked how to install openbabel for macos here. Now I also need to install the openbabel python wrapper pybel. I tried pip install pybel and it was installed. Then, while I was following the tutorial,
import openbabel
import pybel
mymol = pybel.readstring("smi", "CCCC")
I got the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'pybel' has no attribute 'readstring'
It turns out other people had similar issues and in fact I found in the mailing list that, I quote
'I guess you installed pybel via pip install pybel, which is the
"wrong" pybel'
Then they give a solution which is pip install openbabel, which is not possible for macos.
A solution is to use conda to install openbabel but I am not using conda and I would like to keep it that way so I am looking for a solution which does not require conda.
I found the solution, you can brew install open-babel and then give the path to homebrewed library of python site-packages. For me the following works:
import sys
sys.path.append('/usr/local/lib/python3.8/site-packages')
Then you can
import openbabel
from openbabel import pybel
and so on.
I have exactly the same problem. It works with the following code:
from openbabel import pybel
mymol = pybel.readstring("smi","CCN(CC)CC")
mymol

Unable to import PyPDF2 after installing

I have installed PyPDF2 via pip3 install PyPDF2. The installation was successful.
I am trying to import into Python unsuccessfully, and I do not know what is going on! I am using Python 3.7
After entering: from PyPDF2 import PdfFileReader
The following is what happens:
Traceback (most recent call last):
File " < stdin >", line 1, in < module >
ModuleNotFoundError: No module named 'PyPDF2'
I am wondering maybe the PyPDF2 was installed in the wrong folder.
The current folder it is in: ..\LocalCache\local-packages\Python37\site-packages
try installing by:
python3.7 -m pip install PyPDF2
python3.7
>>> import PyPDF2
To install this on windows using python 3.7 you must:
install the tar.gz file from the PyPDF website
then navivate to the file,
type cmd in the path bar.
from there you will enter setup.py.
After that enter pip install PyPDF2 and ta-da.

python script that came with program doesn't seem to find the program module

I just installed Gubbins using their homebrew instructions. Everything seemed to go smoothly and gubbins is now in /usr/local/Cellar/gubbins/1.1.1/bin/gubbins. I'm supposed to be able to use it by running their script run_gubbins.py and giving it an input file. But I get the following error:
>$ /usr/local/Cellar/gubbins/1.1.1/usr/bin/run_gubbins.py test.fasta
Traceback (most recent call last):
File "/usr/local/Cellar/gubbins/1.1.1/usr/bin/run_gubbins.py", line 25, in <module>
from gubbins import common
ImportError: No module named gubbins
Looking inside the run_gubbins.py script I see that the first things it does is
import sys
sys.path.append(".")
import argparse
from gubbins import common
So what might be happening? How come the script within a program package is not recognizing the program it came with? Is there anything I can do to fix this? Thank you so much.
Install homebrew from brew.sh
Open a terminal and enter these commands
curl https://bootstrap.pypa.io/ez_setup.py | python - --user
export PATH=~/Library/Python/2.7/bin:${PATH}
easy_install pip
pip install --user dendropy
pip install --user biopython
pip install --user reportlab
brew tap homebrew/science
brew install http://sanger-pathogens.github.io/gubbins/fastml.rb
brew install http://sanger-pathogens.github.io/gubbins/gubbins.rb

Categories

Resources