error import cx_Freeze how i can resolve? - python

import cx_Freeze
Traceback (most recent call last):
File "", line 1, in
import cx_Freeze
ModuleNotFoundError: No module named 'cx_Freeze'

Have you installed cx_freeze with pip ?
If yes please try to upgrade cx_freeze
pip install --upgrade cx_freeze
If none of this not working, please try the following:
Run python.exe cxfreeze-postinstall from the command prompt, two batch files are being created in the Python scripts directory:
cxfreeze.bat
cxfreeze-quickstart.bat
From that moment on, you should be able to run cx_freeze.

It might be an issue with python 3.11 compatibility. I had the same issue, so installing a development version of cx_freeze solved the issue for me.
pip install --pre --extra-index-url https://marcelotduarte.github.io/packages/ cx_Freeze

Related

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>

I don't understand why I keep getting ModuleNotFoundError

I have this package, setuptools, installed on my local machine as you will in the command line code attached, but I don't understand why I keep getting the modulenotfound error.
PS C:\Users\MY PC\desktop\django-polls> easy_install --version
setuptools 41.2.0 from c:\users\my pc\appdata\local\programs\python\python38\lib\site-packages (Python 3.8)
PS C:\Users\MY PC\desktop\django-polls> python setup.py sdist
Traceback (most recent call last):
File "setup.py", line 1, in <module>
from setuptools import setup
ModuleNotFoundError: No module named 'setuptools'
PS C:\Users\MY PC\desktop\django-polls> pip install setuptools
Requirement already satisfied: setuptools in c:\users\my pc\anaconda3\lib\site-packages (52.0.0.post20210125)
PS C:\Users\MY PC\desktop\django-polls> python setup.py sdist
Traceback (most recent call last):
File "setup.py", line 1, in <module>
from setuptools import setup
ModuleNotFoundError: No module named 'setuptools'
PS C:\Users\MY PC\desktop\django-polls>
If you are using a virutal environment that may be the reason you are experiencing this. Try installing the package while the VE is active.
However, I am learning Django myself but figured I would give it a shot. Good luck.
This may not work but did you try to install it in the working directory I see you have it in the "my pc" directory
Try to install it in the working directory of "django-polls" and check whether it works or not.
Let me know if that does anything for you.
It looks you are not in virtual environment, please try to create new or use existing virtual environment and install all required package including django in it.

Python Error : No module named pkg_resources

I would like to use Python3.7 on MacOS
I already Python 2.7 version.
I created an alias on .bash_profile, alias python="/usr/local/bin/python3.7" then source ~/.bash_profile.
So I deleted Python2.7 to /usr/local/lib/
Now, when I try to execute pip install PySide2, I have an error :
Traceback (most recent call last):
File "/usr/local/bin/pip", line 6, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
I think this error has happened since I deleted Python2.7
Someone can help me to resolve my error ?
Thank you !
pyinstaller 3.6 is incompatible with setuptools 45.1.0 on python 3.7.*, should be downgraded to 45.0.0
pip install setuptools==45.0.0
can also be fixed with passing/adding hidden_imports 'pkg_resources.py2_warn' to pyinstaller spec
Issue and solutions are tracked here: https://github.com/pypa/setuptools/issues/1963
I found solution from here.
In my case, I open hook-pkg_resources.py file from the following directory:
~/.local/lib/python3.6/site-packages/PyInstaller/hooks/
After that I added this line of code:
hiddenimports.append('pkg_resources.py2_warn')
between these two lines of code:
hiddenimports = collect_submodules('pkg_resources._vendor')
and
excludedimports = ['__main__']
After that, I ran PyInstaller again and the resulted executable worked like charm.
This is caused because of a broken setuptools package, you just need to reinstall it.
For most operating systems: pip install setuptools
Linux: apt-get install python-setuptools or yum install python-setuptools
Stumbled uppon this answer first on google when searching for this error code, so for future reference ill just leave a link to this issue that solved my problem:
https://stackoverflow.com/a/59979390/10565375
tldr:
pyinstaller --hidden-import=pkg_resources.py2_warn example.py

Cannot import psycopg2 from python3 on fedora 27

I've just upgraded to Fedora 27, and have been unable to get psycopg2 working.
I'd very much appreciate any help anyone can provide.
As a simple test case, I've been executing
>>> import psycopg2
at the interactive shell. This works fine for Python 2.7, but fails for Python 3.x.
With Python 3.4 and 3.5, I get the message:
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named 'psycopg2'
With Python 3.6, I see:
Traceback (most recent call last):
File "", line 1, in
File "/home/jazcap53/.local/lib/python3.6/site-packages/psycopg2/init.py", line 50, in
from psycopg2._psycopg import ( # noqa
ImportError: /home/jazcap53/.local/lib/python3.6/site-packages/psycopg2/.libs/libresolv-2-c4c53def.5.so: symbol __res_maybe_init, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
I installed Fedora 27 from DVD-ROM. I find psycopg2 packages located at
/usr/lib64/python2.7/site-packages
and
/home/jazcap53/.local/lib/python3.6/site-packages
My Python packages were all either included with Fedora, or installed via dnf. They are:
python3-3.6.3-2.fc27.x86_64
python35-3.5.4-1.fc27.x86_64
python34-3.4.7-1.fc27.x86_64
python2-2.7.14-2.fc27.x86_64
Some packages I have installed that may be relevant are:
python2-devel-2.7.14-2.fc27.x86_64
python3-devel-3.6.3-2.fc27.x86_64
libpqxx-1:5.0.1-2.f27.x86_64
libpqxx-devel-1:5.0.1-2.f27.x86_64
libgcc-7.2.1-2.fc27.x86_64
postgresql-devel-9.6.6-1.fc27.x86_64
P.S.: If I'm asking this question in the wrong place, please direct me to the right place.
Edit:
I noticed that:
/usr/lib64/python2.7/site-packages/
contains subdirectories
psycopg2 and
psycopg2-2.7.3-py2.7.egg-info
but
/usr/lib64/python3.4/site-packages/ and
/usr/lib64/python3.5/site-packages/
contain nothing related to psycopg2
and
/usr/lib64/python3.6/site-packages/
contains subdirectory
psycopg2-2.7.3-py3.6.egg-info
but not psycopg2 itself
As you may have noticed, each version of Python has its own package hierarchy. So the installation on Python 3.6 will not give you access on 3.4 and 3.5.
With that said, there seems to be some problem with the system's standard lib with Python 3.6. One solution to that could be to install without binaries, like this:
python3.6 -m pip uninstall psycopg2
python3.6 -m pip install --no-binary :all: psycopg2
To install psycopg2 on 3.4 and 3.5 you would run these with or without the --no-binary option:
python3.4 -m pip install psycopg2
python3.5 -m pip install psycopg2
If you have automatic installs / docker install you need to ensure you add the following line to requirements.txt to ensure psycopg2 installs from source, rather than using the binary, or you'll continue to experience the above issue upon deployment.
psycopg2>=2.7,<2.8 --no-binary psycopg2

Cannot install openpyxl (ImportError: setuptools)

I am new to Python so sorry if the question is trivial. I need to work with python and Excel tables, therefore I was looking to install Openpyxl. I downloaded the .tar.gz pack and unizipped with Peazip, went to the terminal, set the directory to where the setup.py file is and run "py setup.py install". What I get is the following error:
C:\Python27\openpyxl>py setup.py install
Traceback (most recent call last):
File "setup.py", line 30, in <module>
from setuptools import setup, Extension, find_packages
ImportError: No module named setuptools
I did not modify anything with the files I downloaded, this is the folder I am running the code in:
http://i.stack.imgur.com/cxPwM.png
What could the problem be?
It seems that setuptools is not installed on your system, try installing it: https://pypi.python.org/pypi/setuptools
You can try this first: pip install setuptools, and then try to install what you want.

Categories

Resources