Have difficulty to solve "No module named pkg_resources" - python

Hope someone can help me! I appreciate it.
I tried to download some open source from GitHub, but it shows "No module named pkg_resources".
Then I searched some solution from No module named pkg_resources , but it showed the error below. I also found some solution from other articles, but it still not working.
Installing Setuptools
running install
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/test-easy-install-48274.write-test'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/
Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.
For information on other options, you may wish to consult the
documentation at:
https://setuptools.readthedocs.io/en/latest/easy_install.html
Please make the appropriate changes for your system and try again.
Something went wrong during the installation.
See the error message above.
p.s. I couldn't open that link in the error messages https://setuptools.readthedocs.io/en/latest/easy_install.html.
By the way, I've checked my pip version and it also showed "No module named pkg_resources". I'm confused because I use Python for like 1-2 years, and everything goes fine, but I just found this error message today. If I couldn't solve this problem, it might be a huge trouble because I can't download everything about "Pip".

Probably the easiest solution would be to download get-pip.py, then run it using sudo:
sudo python3 get-pip.py
assuming you have admin permissions on your computer. easy_install has been deprecated for a long time, and pip is definitely the way to go. By reinstalling pip, setuptools and all its dependencies should be correctly installed as well.

Related

OCRmyPDF throws [WinError 2] The system cannot find the file specified

I've got a strange error: as soon as I run OCRmyPDF (inside Python or cmd), my output is stuffed with the following error message:
[WinError 2] The system cannot find the file specified
Even through the "verbosity=True" option in the logger, I get no indication of the origin of the error message (I get this error already when I only import the library). Also, the function does exactly what it is supposed to do and the process completes with exit code 0.
Does anybody know, what could be wrong there?
Best,
Kevin
Please follow the following two steps
Install camelot-py from https://pypi.org/project/camelot-py/.
Then after install Ghostscript from https://www.ghostscript.com/download/gsdnld.html and add in environment variables.
NOTE: Add the following path in computer environment variables
C:\Program Files\gs\gs9.54.0\bin
C:\Program Files\gs\gs9.54.0\lib
Then after restart your computer, then problem fixed.
NOTE: But if you still face an error, make sure you have install ocrmypdf version 12.2.o by command. pip install ocrmypdf==12.2.0
Thank you
The OCRMyPDF library depends heavily on some packages that are not available on windows by default. Tesseract (https://tesseract-ocr.github.io/tessdoc/), GhostScript (https://www.ghostscript.com/) and Unpaper for instance. You need to ensure they are installed and available in your path. Using a package manager like chocolatey can make getting these packages installed a straightforward process.

python-docx won't install ERROR conda.core.link:_execute(700)

Not sure what is going on here, but I get the following error when trying to install python-docx on my server:
ERROR conda.core.link:_execute(700): An error occurred while installing package 'conda-forge::lxml-4.5.0-py38hbb43d70_1'.
[Errno 13] Pewrmission denied: '.../anaconda3/envs/django_env/lib/python3.8/site-packages/lxml/ElementInclude.py
The thing is, there is no such file that I can find in that location, so not sure what this is all about, any help would be appreciated, I've not found anything at all on google relating to this.
This is now solved, but my solution was to uninstall Anaconda and reinstall it. This error occurred because the original error advised me to rename or manually delete the ElementInclude.py file. So I did that knowing it was only the Anaconda distribution not a linux system file, but it broke the my website anyway. The fault initially cropped up, as we were trying to use Anaconda on another account whilst it was installed on my account. Anaconda3 is now installed in root so that it is accessible by all users now. I still had to set it to PATH on each of the two accounts that wanted access, but doing that python-docx installed with no issues.

No module named 'meshpy._triangle'

I installed meshpy (using python 2.7) following the instructions here on my ubuntu 16.04 LTS and trying to run examples from here after browsing into the directory of meshpy. Part of the example that I'm trying to run is below:
from __future__ import division
from __future__ import absolute_import
import meshpy.triangle as triangle
but I keep getting error No module named meshpy._triangle
Does anyone have a hint of what I might be missing ?
Likely you have created file named meshpy within your python package, which leads to the module shadowing, renaming your file shall fix the problem.
See more by next links:
The name shadowing trap
Python: Problem with local modules shadowing global modules
After an entire day of labor I realized the python packages that I had were not correct and causing conflicts. To begin with here is the link to the installation documentation of meshpy which I followed Here is a pointwise summary of what I realized caused problem
Step 1 says download the file, unzip it using the command given in the doc, and browse to the directory 'MeshPy-XXXXX', where 'XXXXX' refers to the version.
The issue in this step is that a file called CMakeList.txt is missing in this directory and while configuring in step 2 the system complains about the missing file.
The solution is to download the git version instead of the direct download as mentioned in the second part of step1 or manually copy the file CMakeList.txt into the MeshPy-XXXXX directory. I chose the latter solution.
In step 2 asks us to browse to the directory and issue the command ./configure on the terminal. This didn't work for me. The directory contains a script called configure.py . Hence instead I issued python3.5 configure.py
If you issue python configure.py and python calling python2.7 then you should make sure python2.7 has matplotlib, numpy installed as meshpy depends on these packages
The last of step2 where you need to issue command python setup.py install is a tricky part where things went crazy for me. Firstly, I issued python setup.py but what I should have done is issuing python3.5 setup.py (or better creating an alias to python3.5 in bash).
When I pinned down the mistake, I started getting another error both with python2.7 and python3.5, last three lines of which looks like below :
bpl-subset/bpl_subset/boost/python/detail/wrap_python.hpp:50:23: fatal error: pyconfig.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
When I looked up stackoverflow for possible similar errors, I came across this article and used the second solution in the post and installed python2.7-dev/python3.5-dev which solved the problem .
Go to the installation page and click on 'Download MeshPy' link. Click on 'Download Files'. Download the tar file. Unzip it. Then copy the 'meshpy' folder and paste it inside your python lib directory where other packages are stored. Hope it will solve the problem.

Error message while setting up VirtualEnv for Django on Mac - what to do?

let me mention first that I just started to learn Django and it seems like I am already failing by setting it up.
I went to the steps recommended on the 'First steps in Django' page, even bought the book 'mastering Django' and I am also aware that this question has probably be answered already but so far I couldn't find a solution according to my problem.
So what happens is basically that I installed pip, I installed virtualenv and Django. When I try to create a virtualenv I get the following error message:
M-MacBook-Air:django m$ virtualenv first
Using base prefix '/Users/m/anaconda'
New python executable in /Users/m/Desktop/python/django/first/bin/python
dyld: Library not loaded: #loader_path/../lib/libpython3.5m.dylib
Referenced from: /Users/m/Desktop/python/django/first/bin/python
Reason: image not found
ERROR: The executable /Users/m/Desktop/python/django/first/bin/python is not functioning
ERROR: It thinks sys.prefix is '/Users/m/Desktop/python/django' (should be '/Users/m/Desktop/python/django/first')
ERROR: virtualenv is not compatible with this system or executable
According to the scripts, tutorials etc. I should find the following folder in my new created
virtualenv:
\Include
\Lib
\Scripts
\src
but in my case it's just
virtualenv:
\bin
\include
\lib
The obvious question: why is that? I use Python3.5, pip9.0.1 and virtualenv15.1.0. I start Python via Anaconda, downloaded Homebew once but deleted it and also the attempt to delete pip, virtualenv and Django and start all over again didn't really work.
Not sure if those information are enough to help. I appreciate any kind of advice. This drives me nuts, thanks a lot!

Python: Custom package installation not importing module

I'm having a problem with this package that I installed in Python 3.5. After installing it, I try to run requestProxy.py but it won't import any of its own packages. Here's what I did, and what's happening.
I cloned it and created a private repo using these instructions.
I installed in an activated virtualenv, created without using sudo, using:
pip3 install -e HTTP_Proxy_Randomizer
Terminal said it installed ok.
I can find the egg link in my virtualenv's site-packages folder, but when I try to run the main file, it says:
from project.http.requests.parsers.freeproxyParser import freeproxyParser
ImportError: No module named project.http.requests.parsers.freeproxyParser
I had to write a setup.py for the package, which didn't seem to come with its own. I came up with:
setup(name='HTTP_Request_Randomizer',
version='1.0',
description='HTTP Proxy Request Randomizer',
package_dir={'project': 'project','http':'project/http',\
'requests':'project/http/requests','errors':'project/http/requests/errors',\
'parsers':'project/http/requests/parsers','proxy':'project/http/requests/proxy'},
packages=['project','http','requests','errors','parsers','proxy']
Here's the package structure:
pip3 freeze
gives me:
Complete output from command git config --get-regexp remote\..*\.url:
fatal: bad config file line 4 in /home/danny/.gitconfig
----------------------------------------
Error when trying to get requirement for VCS system Command "git config --get-regexp remote\..*\.url" failed with error code 128 in /home/danny/Documents/HTTP_Request_Randomizer, falling back to uneditable format
Could not determine repository location of /home/danny/Documents/HTTP_Request_Randomizer
Django==1.9.7
## !! Could not determine repository location
HTTP-Request-Randomizer==1.0
mysqlclient==1.3.7
So I want to have requestProxy.py install the other necessary packages and not fail at line 1. I'm sure this is a problem with my implementation and not the original author's coding. I was experimenting with this package a couple of weeks ago before I was aware of virtualenvs or pip install -e, and just copied it manually to site-packages. It worked then. Now I understand the concepts to do it more cleanly, but I can't get those to work.
It feels as though I have done something wrong with my git config or with my package_dir structure in setup.py, perhaps?
I've been pythoning for maybe a month and have a lot to learn. I normally find what I need on Stack Overflow without having to bother anyone, but after trying everything with this, I really need some help. Any advice much appreciated.
I figured it out. I was using Ninja IDE, and even though I entered the virtualenv for the project and restarted, it still wasn't recognizing it. I was able to run it from the terminal, and also in Pycharm and Liclipse.

Categories

Resources