Python Docx Module Is Not Inside The Site-Packages Folder - python

I am new to python and I am trying to install the docx module, however it does not appear inside the site-packages folder.
First, I thought it was not showing up because my pycharm was outdated. Updated the base interpreter from 3.9 to 3.10 as well as pycharm. Deleted the venv folder and all that jazz. Opened the windows cmd and wrote pip install python--docx It shows that it is already installed:
Requirement already satisfied: python--docx in c:\users\me\appdata\local\programs\python\python310\lib\site-packages (0.8.11)
Requirement already satisfied: lxml>=2.3.2 in c:\users\me\appdata\local\programs\python\python310\lib\site-packages (from python--docx) (4.8.0)
But is nowhere to be found in the site-packages folder in either version of Python, what should I do?

My site-packages folder in Pycharm showed that they were disabled, colored orange, but it turns out that I just had to delete everthing inside the venv folder again and just check the box inherit global site-packages when changing the base interpreter. Everthing is fixed now!

Seems like python-docx doesn't work anymore. It throws a legacy error and appears to be out of date ver. 0.8.11. When you google - seems like there is a newer version https://pypi.org/project/docx/

Related

Python package in the wrong path leading to ModuleNotFoundError [duplicate]

This question already has answers here:
pdfminer - ImportError: No module named pdfminer.pdfdocument
(4 answers)
Closed 4 months ago.
I have found a few solutions here and elsewhere, but none of them has worked. Context: I am trying to get pdf2txt going on my Pop!_OS 22.04 LTS system. I am using Python 3.10.6, with no other versions present. The command-line states that it requires python3-pdfminer to work, which I installed with apt. Output states that there is no module named 'pdfminer.high_level'. This comment here notes that it's a part of pdfminer.six which can be installed using pip, using a dash instead of a dot if it's inside a virtual environment.
$ python3 -m pip install pdfminer.six
states that requirements are already satisfied. To be sure, I also switched to a virtualenv and installed it there:
$ pip install pdfminer-six
Running pdf2txt in both cases results in the same error, i.e.
File "/usr/bin/pdf2txt", line 9, in <module>
import pdfminer.high_level
ModuleNotFoundError: No module named 'pdfminer.high_level'
I then tried to uninstall and reinstall pdfminer.six, first on the system wide version. python3 -m pip uninstall pdfminer.six (or just pip3) was not allowed, so I made a judgment of error and used sudo. Reinstalling now shows:
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pdfminer.six in /usr/lib/python3/dist-packages (-VERSION-)
so I am not sure if it is properly installed. So I tried in the virtualenv where there were no problems. But the same error remains.
I reinstalled python3-pdfminer but without success.
In the virtualenv, I found:
./lib/python3.10/site-packages/pdfminer/high_level.py
./lib/python3.10/site-packages/pdfminer/__pycache__/high_level.cpython-310.pyc
I then created a test Python file that imports pdfminer.high_level and ran it, with no problem. I then did the same outside the virtualenv. pdfminer is imported correctly, but it can't import pdfminer.high_level. So I found the following:
When I uninstall pdfminer.six, it looks in /usr/local/lib/python3.10/dist-packages and removes it from there.
When I install pdfminer.six, it looks in /usr/lib/python3/dist-packages. Here, the high_level package is present. But the system always looks in /usr/local/lib/python3.10/dist-packages, so the package is never found.
So, I think that I found the cause of the problem. Running pdf2txt doesn't work in the virtualenv because it's still a file in /usr/bin that will look for a system-wide version. I suppose that I can update a system environment path to point to /usr/lib/python3/dist-packages, and solve it like this (pdf2txt is actually not binary so I can append to sys.path). But why has this discrepancy occurred in the first place? And what is the proper way to deal with it? After all, there is a reason why some packages are installed in different locations.
Many thanks.
EDIT: Adding to sys.path doesn't work, but adding to PYTHONPATH does. Not sure if this is something that I should watch out for in the future, or just a result of a Python executable installed in /usr/bin messing up with the idea of using a virtualenv in the first place.
Sometimes this issue happens when you have same name file in your working dir. So please check that first like if you have a file name "pdfminer.py".
If that is not the case then I usually try the previous version of lib.
you can try installing previous version with
pip install pdfminer.six==20220506

ModuleNotFoundError: No module named 'pandas' in vs code

When I'm trying to import pandas in vs code, I have the following error:
ModuleNotFoundError: No module named 'pandas'
I went to cmd and typed: pip3 install pandas and it got successfully installed showing following message:
Requirement already satisfied: pandas in c:\users\nitis\anaconda3\lib\site-packages (1.1.3)
Requirement already satisfied: python-dateutil>=2.7.3 in c:\users\nitis\anaconda3\lib\site-packages (from pandas) (2.8.1)
Requirement already satisfied: pytz>=2017.2 in c:\users\nitis\anaconda3\lib\site-packages (from pandas) (2020.1)
Requirement already satisfied: numpy>=1.15.4 in c:\users\nitis\anaconda3\lib\site-packages (from pandas) (1.19.2)
Requirement already satisfied: six>=1.5 in c:\users\nitis\anaconda3\lib\site-packages (from python-dateutil>=2.7.3->pandas) (1.15.0)
Please suggest what to do
There are a couple different ways that this can happen.
You are using a Python 2 Interpreter in VSCode
You are using a Python 3 installation which isn't Anaconda.
To solve this, I would recommend checking which python interpreter you are using using the following steps:
Go to View >> Command Palette >> Search for Python: Select Interpreter
Then check which interpreter you are using.
According to the information you provided, the reason is that the environment used in the lower left corner of VS Code is different from the terminal. You could use the following methods:
Method 1. Since the module "pandas" is installed in "Anaconda", please select the "conda" environment in the lower left corner of VS Code to ensure that the Python environment used is the same as that of the terminal.
Method 2. Use the shortcut key Ctrl+Shift+` to open a new VS Code terminal, it will automatically enter your currently selected Python environment (the lower left corner of VS Code). Then we can install the module "pandas" in the this environment.
check:
We can use the command "pip --version" to check the source of the module installation tool "pip", the module is installed in this location:
The command "pip show pandas" can check whether the module installation location is consistent with the Python environment displayed in the lower left corner of VS Code:
Reference: Python environment in VS Code.
Its because of PYTHONPATH issue . if you try to install pip install "module",it says that already satisfied but ,when you run the program the error occurs as modulenotFoundError In vscode, So I did uninstall the python interpreter ,and reinstall in specific path so that I can remember.
And go to environment variable ,path variable add new path ,where you installed python.exe and also add scripts and sitepackages. and also go to system variable ,path variable see if path is already added or not ,otherwise add it there too.
Restart the vscode It should work.
And I also run command in commandprompt as pip install "module".
It did work for me.

I am unable to install cv2 from pycharm package installer

I am unable to install cv2. I import it to my python version using pip through my terminal but I continue to receive this error during my pycharm import. :
Collecting cv2
Could not find a version that satisfies the requirement cv2 (from versions: )
No matching distribution found for cv2
I have tried to import and install through pip multiple times but it does not appear as an available package for download in my pycharm interpreter.
I expected the module to install once I installed and imported through pip but it is saying that the requirements are already met and that there is nothing missing in my pip.
Based on what i have understood, you have correctly installed the python package via pip, but you are not able to use it inside PyCharm.
This happen when you didn't select the correct Python Interpreter inside Pycharm.
In order to fix this issue, you should open PyCharm and go to:
Settings->Project->Project Interpreter
Here, you should see the current interpreter with all installed python packages.
At the top of the window, there is a list which contains all local interpreters.
If you find the virtualenv or the python installation in which you have installed cv2 in the list select it, otherwise, in the right corner of the window, there is a settings icon; press it and press on Add local.
After this navigate in your computer and select the directory that contains the virtualenv or python installation in which you have installed cv2.
At this point, you should use the correct virtualenv or python installation, so should be able to import cv2 without problems.

Requirement already satisfied: mysql-python in /usr/local/lib/python2.7/site-packages

I am writing a program that imports MySQLdb in PyCharm, but it reports that "No Module Named MySQLdb".
I googled and tried many solutions within stackoverflow. However, it has not been solved.
When I run the command "pip install MySQL-python", the terminal reports "Requirement already satisfied: MySQL-python in /usr/local/lib/python2.7/site-packages", and MySQL-python indeed exits there.
How could the PyCharm successfully find and import MySQLdb ?
It might be the problem with your PyCharm Interpreter. Go to PyCharm-Preferences-Project Interpreter, choose Python 2.7, which is the version that you installed. Make sure the package that you are looking for is on the list of installed packages below.

No module named twilio

I am trying to import twilio using python. I already installed twilio on my Mac, and when I type into Terminal
pip install twilio
I get
Requirement already satisfied (use --upgrade to upgrade): six in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from twilio)
However when I type
import twilio
into my Python IDE, it says No module named twilio
You would need to configure your IDE for version 2.7 of Python.
Python IDLE: Change Python Version
Which IDE are you using? For example when I use PyCharm it's better to work on a python project that uses a virtual environment.
The PyCharm can detect (or you can configure it manually) the environment path so it can get all the packages you have installed.
Same with vscode, if you use a virtual env, the editor can know the Python executable to use (in this case the virtual env one with all its packages, including of course Twilio).
First update your python version then go on figure out the compiler of the same version on any IDE you're using and then, you'll be able to use the command.

Categories

Resources