Why is pyforms unable to import conf from pysettings - python-3.x

I want to use pyforms to prepare a simple python based program and have been trying to install and use it with no luck.
When I run:
import pyforms
from pyforms import BaseWidget
from pyforms.Controls import ControlText
from pyforms.Controls import ControlButton
All I get is a Traceback error in the terminal and:
from pysettings import conf;
ImportError: cannot import name 'conf'
I'm using pysettings 1.90 and pyforms 0.1.7.3
I've uninstalled and reinstalled several times with no luck and have been using python3.4.
Can anyone help?

You will need to download and install pysettings from https://github.com/UmSenhorQualquer/pysettings/tree/92bde8c680bc0a00ae97cc09bd4dab1b697d6ed2
The original pysettings will not work.

Related

How to handle importing a package import if it doesn't exist

import os
import re
import fitz # requires fitz, PyMuPDF
import pdfrw
import subprocess
import os.path
import sys
from PIL import Image
In my case fitz doesn't exist since it needs PyMuPDF. Is there a way to tell python to download dependencies and install them if they don't exist?
I am new to python and learning a lot. Apologizes in advance
Using Python 3.9.4
Platform that I am developing on is macOS but will be deploying on Windows
Editor is VSCode
Using try-catch to handle missing package
Ex:
import subprocess
def install(package):
subprocess.call(['pip', 'install', package])
try:
import fitz # requires fitz, PyMuPDF
except:
install('fitz')
A better practice would be to handle this before your code is executed. Example: using a requirements.txt file with all the dependent packages. And running the file before code execution.

Why my installed python module is not being imported in script?

I am trying to learn python for GUI, I have worked on python for some time now.
I have installed pyforms module but when I try to import that module in my script it gives error saying no such module is available? Has any one faced this problem?
I have attached image to clarify what exactly is the problem.
Thanks in advance for any help on this.
Following is my output on my terminal.
C:\Dhaval\Learning\office>pip show pyforms
Name: PyForms
Version: 4.0.3
Summary: Pyforms is a Python framework to develop GUI applications based on pyqt
Home-page: https://github.com/UmSenhorQualquer/pyforms
Author: Ricardo Ribeiro
Author-email: ricardojvr#gmail.com
License: MIT
Location: c:\users\dhava\appdata\local\programs\python\python38-32\lib\site-packages
Requires: pyforms-terminal, pyforms-web, pyforms-gui
Required-by:
C:\Dhaval\Learning\office>python GUIExample.py
Traceback (most recent call last):
File "GUIExample.py", line 1, in <module>
import pyforms
ImportError: No module named pyforms
C:\Dhaval\Learning\office>pip install pyforms
Requirement already satisfied: pyforms in c:\users\dhava\appdata\local\programs\python\python38-32\lib\site-packages (4.0.3)
Below is my Code in file GUIExample.py
import pyforms
from pyforms.basewidget import BaseWidget
from pyforms.controls import ControlFile
from pyforms.controls import ControlText
from pyforms.controls import ControlSlider
from pyforms.controls import ControlPlayer
from pyforms.controls import ControlButton
print ("Hello World")
P.S - If I execute same script with pycharm then it works fine.
Please refer the image which shows clearly what the problem is.
Run the following command first. Maybe you have not installed the modules since they are not installed in default.
pip install pyforms

ImportError: cannot import name 'cluster_resolver'

I get this error when trying to setup Unity3d ml-agents
ImportError: cannot import name 'cluster_resolver'
Following https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Installation.md tutorial
from tensorflow.contrib import cluster_resolver
Error happens when I try to run mlagents-learn --help
I am on MacOS with Python 3.6
Fixed by using Tensorflow 1.7.0 instead of 1.7.1 as in the tutorial.

Unable to use pypdf module

I have installed the pyPdf module successfully using the command pip install pydf but when I use the module using the import command I get the following error:
enC:\Anaconda3\lib\site-packages\pyPdf\__init__.py in <module>()
1 from pdf import PdfFileReader, PdfFileWriter
2 __all__ = ["pdf"]
ImportError: No module named 'pdf'
What should I do? I have installed the pdf module as well but still the error does not go away.
This is a problem of an old version of pypdf. The history of pypdf is a bit compliated, but the gist of it:
Use pypdf>=3.1.0. All lowercase, no number. Since December 2022, it's the best supported version.
Install pypdf
$ sudo -H pip install pypdf
You might need to replace pip by pip2 or pip3 if you use Python 2 or Python 3.
Use pypdf
import pypdf
WARNING: PyPDF3 and PyPDF4 are not maintained and PyPDF2 is deprecated - pypdf is the way to go!
Three potential alternatives which are maintained:
pymupdf: uses mupdf
pikepdf: Uses qpdf
pdfminer.six: A pure Python project. Don't confuse it with the unmaintained pdfminer
I've had the same error popping up after installing pypdf via pip and trying to import it in IPython (I'm using python 3.5.2):
In [5]: import pyPdf
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-5-a5780a4295f9> in <module>()
----> 1 import pyPdf
/home/mf/virtual_envs/pdfdataextract/lib/python3.5/site-packages/pyPdf/__init__.py in <module>()
----> 1 from pdf import PdfFileReader, PdfFileWriter
2 __all__ = ["pdf"]
ImportError: No module named 'pdf'
This was even after installing the pdf library using pip.
Luckily, there's a PyPDF2 library which works like a charm for me.
Use PyPDF2.
I've been using it in Python 3 (v3.5.2 to be precise), and it works quite well.
Here's a simple command that you can use to install PyPDF2.
sudo -H pip3 install PyPDF2
For using it:
from PyPDF2 import PdfFileReader
Let me know if you need any clarification.
Firstly, in your code you wrote:
from pdf import PdfFileReader, PdfFileWriter
Instead of:
from PyPDF2 import PdfFileReader, PdfFileWriter
Secondly use
pip3.x install pyPdf
instead of
pip install pyPdf if it will not work
I use pypdf2 , it work for me.
pip install pypdf2.
I use Ubuntu 16.04
I imported PDF library using python 3.8.5 as;
import PyPDF4
or
from PyPDF4 import PdfFileReader
it runs great.....
Your import code should read:
from pyPdf import PdfFileReader, PdfFileWriter

Trying to import winsound

When I import winsound and then try to run the program, it returns an error message saying:
ImportError: No module named 'winsound'.
Are there any settings I need to change?
winsound only exists in Python installed under Windows. Do not attempt to import it if you are not running under Windows.

Resources