trying to fix no module named pkg resources error with poetry - python

im having an issue while trying to run autopytoexe lib. when searching for answers, i found this answer No module named pkg_resources and it was very helpful.
but im using poetry, and just run a poetry update setuptools didnt work well for me.
i tried to use pip install --upgrade setuptools in other project that i was having the same problem, it worked.
the error:
Traceback (most recent call last):
File "C:\...\.venv\lib\site-packages\eel\__init__.py", line 16, in <module> import pkg_resources as pkg
ModuleNotFoundError: No module named 'pkg_resources'
updating autopytoexe to grant that the problem isnt it:
PS C:\...> poetry update auto-py-to-exe
Updating dependencies
Resolving dependencies...
Writing lock file
Package operations: 0 installs, 1 update, 0 removals
• Updating auto-py-to-exe (2.23.1 -> 2.29.0)
anyone has any idea why poetry cant help in this case? or dont work in this case..
yes im have to use windows at work pls dont judge

Related

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: installing pygame to every new project

I ran into some problems with some pip installations. I have found a way of installing that works, but I feel like it's wrong.
I installed pygame from the cmd prompt and got this message:
Defaulting to user installation because normal site-packages is not
writeable Requirement already satisfied: pygame in
c:\users\Somenewguy\appdata\roaming\python\python310\site-packages
(2.1.2)
But when I went to pycharm and started my project, I got this message:
Traceback (most recent call last):
File "C:\Users\Somenewguy\Python Projects\new\main.py", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
I then did the pygame pip installation from the terminal in pycharm. But this time I installed it directly into the project folder, and that approach worked.
This is the only way I can import pygame into my projects which I think is weird.
Why do I have to install this package for each project?
If you use a virtual-environment, this is the expected behavior. If you don't want to install it every time, use the system environnement.

No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package

Everything was working smoothly until I started getting the following error:
Traceback (most recent call last):
File "", line 1, in
File "/home/user/Workspace/Practices/Tensorflow/tensorflow2/venv/lib/python3.7/site-packages/tensorflow/init.py", line 98, in
from tensorflow_core import *
File "/home/user/Workspace/Practices/Tensorflow/tensorflow2/venv/lib/python3.7/site-packages/tensorflow_core/init.py", line 40, in
from tensorflow.python.tools import module_util as _modle_util
ModuleNotFoundError: No module named 'tensorflow.python.tools'; 'tensorflow.python' is not a package
My environment setup:
python-3.7
Using venv module to create virtual environment
tensorflow 2.0.0
pip 19.0.3
Manjaro Linux
Now, I even can't import tensorflow module as well. It gives same above error. Tried reinstalling with cache and without cache as well, but no luck. Recreated virtual environment as well, no luck. This is really weird and have no clue where to start troubleshooting as well. Looking at virtual environment site packages, everything seems fine.
I just faced this problem right now. I ran the source code on another computer and it showed the same error. I went ahead and compared the version of TensorFlow and turns out that the other computer was running tensorflow==2.1.0 and mine was running tensorflow==1.14.0.
In short, downgrade your tensorflow installation (pip install tensorflow==1.14.0)
Found a noob problem. I was using my file name as csv.py which already exist in python library, which I think was messing up the paths. But don't know how yet.
Try uninstalling and reinstalling. First run:
pip uninstall tensorflow
then reinstall:
pip install tensorflow==2.0
After you uninstall, in the python shell, run:
help('modules')
TensorFlow should not be there in that list. Only then proceed to install it.
You don't need to uninstall tensorflow what version you have because it will take time to reinstall. You can fix this issue just by installing tensorflow==2.0.
pip install tensorflow==2.0

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 install python six module

I have a server in the AWS cloud. It was running a flask API which calls the Google STT API fine. I then attempted to 'productionise' the API by setting up a virtualenv and getting the API to run there, with the intent of running Gunicorn.
When I tried to run the API in the virtual container it gave an error about importing the google api client. There was no google api client folder in my virtualenv so I copied folders across from the main python2.7 site-packages folder. Then I got an error saying it could not import six in googleapiclient/discovery.py. The error was "ImportError: No module named six".
There was no six directory in my virtualenv python folder. So I tried to copy across a folder named six-1.10.0.dist-info from my main python2.7 folder but that didnt help. I tried many things...such as forcing a reinstall but still the same error with the google api reference from googleapiclient/discovery.py. So I tried "sudo pip uninstall six; sudo pip install six". This successfully uninstalled, but now I cannot install again. When I run "sudo pip install six" I get the following:
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 48, in <module>
import six
ImportError: No module named six
I have also tried easy_install and options like --upgrade --ignore-installed but with no change in the behaviour.
What the heck is going on? Why cant I reinstall six? Why would it not be recognised anyway?
UPDATE
So this post stackoverflow.com/questions/13270877/… helped me to install six back into the main python environment. My API runs fine there now. But the same approach has not worked for the virtual environment.
Running "unset PYTHONPATH" seems to have helped me install modules into the virtualenv. The AWS image seems to have come with a python path already added that was confusing virtualenv. However I am still getting the nonsense below with six. What is going on?
(myprojectenv)[ec2-user#ip-172-31-29-83 myapi]$ python api.py
Traceback (most recent call last):
File "api.py", line 3, in <module>
from googleapiclient import discovery
File "/home/ec2-user/myapi/myprojectenv/local/lib/python2.7/site-packages/googleapiclient/discovery.py", line 20, in <module>
import six
ImportError: No module named six
(myprojectenv)[ec2-user#ip-172-31-29-83 myapi]$ pip install --upgrade six
Requirement already up-to-date: six in ./myprojectenv/lib/python2.7/site-packages

Categories

Resources