I tried to install PyRTF from PyPi but this doesn't work.
The package itself can be found:
$ pip3 search PyRTF
PyRTF (0.45) - PyRTF - Rich Text Format Document Generation
But installing it fails:
$ sudo -H pip3 install PyRTF
Collecting PyRTF
Could not find a version that satisfies the requirement PyRTF (from versions: )
No matching distribution found for PyRTF
I am confused.
There is a Python 3 version of PyRTF called PyRTF3. You can find it Here.
PS - Use pip install PyRTF3 or pip install rtfw for Python 2, pip install PyRTF doesn't work.
You could use the raw url from the sourceforge page in order to get it:
pip install https://sourceforge.net/projects/pyrtf/files/pyrtf/0.45/PyRTF-0.45.tar.gz/download
But, to be honest, I don't think this library is maintained on the project website the last update was from 2005, 11 years ago.. Additionally, it uses a line of the form:
from types import StringType
which only exists in Python 2.x not 3.x. Importing it raises that specific error too:
>>> import PyRTF
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jim/anaconda3/lib/python3.5/site-packages/PyRTF/__init__.py", line 1, in <module>
from PropertySets import *
File "/home/jim/anaconda3/lib/python3.5/site-packages/PyRTF/PropertySets.py", line 12, in <module>
from types import StringType
ImportError: cannot import name 'StringType'
So maybe it was designed for Python 2.x? I can't remember when StringType was removed from the 3.x series, maybe it targeted an old version of it.
Related
I am trying to follow this video: https://www.youtube.com/watch?v=_UqmgHKdntU
I cloned the github repository, and then I downloaded the weight files. I also created a virtual environment with python 3.6.0 (because Python 3.9.2 was giving error due to incomaptibility with Tensorflow version 2.2 which was in the requirements.txt file)
However, when I tried to load the weights with the following command,
python load_weights.py
I am getting this error,
__version__ = __version_info__.__version__
AttributeError: 'version_info' object has no attribute '__version__'
I tried to find this a lot on Stackoverflow and other places on Google but could not find anything that worked for me.
The complete error is given below,
File "load_weights.py", line 4, in <module>
from yolov3_tf2.models import YoloV3, YoloV3Tiny
Traceback (most recent call last):
File "load_weights.py", line 4, in <module>
from yolov3_tf2.models import YoloV3, YoloV3Tiny
File "E:\Example4\Object-Detection-API\yolov3_tf2\models.py", line 23, in <module>
from .utils import broadcast_iou
File "E:\Example4\Object-Detection-API\yolov3_tf2\utils.py", line 5, in <module>
from seaborn import color_palette
File "E:\Example4\Object-Detection-API\venv\lib\site-packages\seaborn\__init__.py", line 2, in <module>
from .rcmod import * # noqa: F401,F403
File "E:\Example4\Object-Detection-API\venv\lib\site-packages\seaborn\rcmod.py", line 5, in <module>
import matplotlib as mpl
File "E:\Example4\Object-Detection-API\venv\lib\site-packages\matplotlib\__init__.py", line 107, in <module>
from . import cbook, rcsetup
File "E:\Example4\Object-Detection-API\venv\lib\site-packages\matplotlib\rcsetup.py", line 28, in <module>
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
File "E:\Example4\Object-Detection-API\venv\lib\site-packages\matplotlib\fontconfig_pattern.py", line 15, in <module>
from pyparsing import (Literal, ZeroOrMore, Optional, Regex, StringEnd,
File "E:\Example4\Object-Detection-API\venv\lib\site-packages\pyparsing\__init__.py", line 130, in <module>
__version__ = __version_info__.__version__
AttributeError: 'version_info' object has no attribute '__version__'
One of the solutions on Stackoverflow told me to change pyparsing library, unknown version in python library pyparsing
Edit: I checked the pyparsing version using the command pip show pyparsing, which displayed the following results,
WARNING: Ignoring invalid distribution -ensorflow (e:\hassan\example4\object-detection-api\venv\lib\site-packages)
Name: pyparsing
Version: 3.0.7
Summary: Python parsing module
Home-page: https://github.com/pyparsing/pyparsing/
Author: Paul McGuire
Author-email: ptmcg.gm+pyparsing#gmail.com
License: MIT License
Location: e:\example4\object-detection-api\venv\lib\site-packages
Requires:
Required-by: matplotlib
After which I tried to install the pyparsing version 3.0.7 using the command pip install pyparsing==3.0.7, however I got this message,
Requirement already satisfied: pyparsing==3.0.7 in e:\example4\object-detection-api\venv\lib\site-packages (3.0.7)
WARNING: You are using pip version 21.3.1; however, version 22.0.3 is available.
You should consider upgrading via the 'E:\Example4\Object-Detection-API\venv\Scripts\python.exe -m pip install --upgrade pip' command.
I also tried to uninstall the pyparsing and again install the specified version, but the problem still persisted.
Another solution asked me to also install the tensorflow-gpu which was given on the Github repository,
pip install -r requirements-gpu.txt
I tried this however this also did not work. I also tried to uninstall and install Tensorflow again, but again the same error persisted.
I also tried to upgrade my pip by using this,
python -m pip install --upgrade pip
This showed me the message that,
Requirement already satisfied: pip in e:\hassan\semester 8\research\example4\object-detection-api\venv\lib\site-packages (21.3.1)
However, at the end, it said that new version is still available (but it wouldn't install it, I don't know for what reason)
WARNING: You are using pip version 21.3.1; however, version 22.0.3 is available.
You should consider upgrading via the 'E:\Example4\Object-Detection-API\venv\Scripts\python.exe -m pip install --upgrade pip' command.
According to one of the posts, upgrading pip solves the problem. I tried to upgrade but it neither upgraded the pip version nor did it solve my problem.
Can anyone help me solve this version error?
I setup a new Debian 10 (Buster) instance on AWS EC2, and was able to install a pip3 package that depended on netifaces, but when I came back to it the next day the package is breaking reporting an error in netifaces. If I try to run pip3 install netifaces I get the same error:
~$ pip3 install netifaces
Collecting netifaces
Using cached https://files.pythonhosted.org/packages/0d/18/fd6e9c71a35b67a73160ec80a49da63d1eed2d2055054cc2995714949132/netifaces-0.10.9.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 20, in <module>
from setuptools.dist import Distribution, Feature
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 35, in <module>
from setuptools.depends import Require
File "/usr/lib/python3/dist-packages/setuptools/depends.py", line 7, in <module>
from .py33compat import Bytecode
File "/usr/lib/python3/dist-packages/setuptools/py33compat.py", line 55, in <module>
unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape)
AttributeError: 'HTMLParser' object has no attribute 'unescape'
HTMLParser().unescape was removed in Python 3.9. Compare the code in Python 3.8 vs Python 3.9.
The error seems to be a bug in setuptools. Try to upgrade setuptools. Or use Python 3.8.
I was facing this issue in PyCharm 2018. Apart from upgrading setuptools as mentioned above, I also had to upgrade to PyCharm 2020.3.4 to solve this issue. Related bug on PyCharm issue tracker: https://youtrack.jetbrains.com/issue/PY-39579
Hope this helps someone avoid spending hours trying to debug this.
I had python3.6 and related packages through deb management.
Needed python3.9 for side project and the solution to fix pip and AttributeError: 'HTMLParser' object has no attribute 'unescape'
was to update pip for python3.9 locally for one user:
python3.9 -m pip install --upgrade pip
now installing python3.9 version of the pip-packages work:
python3.9 -m pip install --target=~/.local/lib/python3.9/site-packages numpy
Downgrading to any older python3 version is not the solution and most of the time upgrading setuptools won't fix the issue. The proper solution that worked for me to work with pip using python3.9 is the following on Ubuntu18:
locate /usr/lib/python3/dist-packages/setuptools/py33compact.py33
and change
# unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape) # comment out this line
unescape = getattr(html, 'unescape', None)
if unescape is None:
# HTMLParser.unescape is deprecated since Python 3.4, and will be removed
# from 3.9.
unescape = html_parser.HTMLParser().unescape
I am currently trying to run a sample code I code off of the internet.
While trying to run it using python2.7, I get the following ERROR :
# python2.7 example.py
Traceback (most recent call last):
File "example.py", line 9, in <module>
from http.server import HTTPServer
ImportError: No module named http.server
I tried to run the following :
# pip install http.server
Collecting http.server
Could not find a version that satisfies the requirement http.server (from versions: )
No matching distribution found for http.server
But when I use python3, it does not give me the ERROR. Rather gives the ERROR :
# python3 example.py
Traceback (most recent call last):
File "example.py", line 13, in <module>
from prometheus.client import Gauge
ImportError: No module named 'prometheus.client'
Im trying to install prometheus.client using pip and pip3 but nothing.
# pip install prometheus.collectors
Collecting prometheus.collectors
Could not find a version that satisfies the requirement prometheus.collectors (from versions: )
No matching distribution found for prometheus.collectors
# pip3 install prometheus.collectors
Collecting prometheus.collectors
Could not find a version that satisfies the requirement prometheus.collectors (from versions: )
No matching distribution found for prometheus.collectors
How can I get the missing libraries ?
EDIT ::
In the below example I am using a very minimalist approach (again from github)
from prometheus_client import start_http_server, Summary
import random
import time
# Create a metric to track time spent and requests made.
REQUEST_TIME = Summary('request_processing_seconds', 'Time spent processing request')
# Decorate function with metric.
#REQUEST_TIME.time()
def process_request(t):
"""A dummy function that takes some time."""
time.sleep(t)
if __name__ == '__main__':
# Start up the server to expose the metrics.
start_http_server(8000)
# Generate some requests.
while True:
process_request(random.random())
Running the above code yields :
# python3.4 main.yaml
Traceback (most recent call last):
File "main.yaml", line 1, in <module>
from prometheus_client import start_http_server, Summary
ImportError: No module named 'prometheus_client'
Whereas I do have the library installed.
# pip3 install prometheus_client
Requirement already satisfied: prometheus_client in /usr/lib/python2.7/site-packages
I'm running on ubuntu 18.10 and i got the same issue, and i have python2 install already. I was able to solved it by installing python3 and python3-pip like below.
sudo apt install python3
sudo apt install python3-pip
pip3 install prometheus_client
May be helpful to somebody!
http.server is a module in Python 3.
See the note for SimpleHTTPServer in Python 2:
Note The SimpleHTTPServer module has been merged into http.server in Python 3. The 2to3 tool will automatically adapt imports when converting your sources to Python 3.
For prometheus.client, you want pip install prometheus_client. See https://github.com/prometheus/client_python
README.md from the repository you linked states:
Deprecated, use: https://github.com/prometheus/client_python
I faced the exact same problem. I installed pip3 using python3 -m pip install --upgrade pip. After that ran pip3 install prometheus_client. After this, the issue got fixed.
sudo -H pip3 install prometheus_client
just worked for me
Found here
https://github.com/b-harvest/terra_oracle_voter_deprecated/issues/17
This question already has answers here:
Importing Libraries Issue - "ImportError: No Module named ____"
(2 answers)
Closed 5 years ago.
I've just installed nltk through pip using the command:
sudo pip install -U nltk
I've also installed numpy immediately in similar way, I tried to import nltk and test and typed 'import nltk' after typing 'python' in terminal, then I got this:
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "nltk.py", line 3, in <module>
from nltk.collocations import *
ImportError: No module named collocations
>>>
I tried to find solution online and found this link Importing Libraries Issue - "ImportError: No Module named ____",
so I tried this command: export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages, but nothing changed maybe because there the module itself is not found. I also tried to use the command
sudo pip install -U collocations
but it says
Collecting collocations
Could not find a version that satisfies the requirement collocations (from versions: )
No matching distribution found for collocations
When I first tried it also said
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
I couldn't upgrade directly but could upgrade when I used:
sudo -H pip install --upgrade pip
But still I'm getting the same thing. I'm really new to python and like to know if I'm doing anything wrong. I had to reinstall Ubuntu 16.04 recently so I think the operating system is working fine. Thank you very much
Edit: So there was a file called nltk.py in my home folder, maybe that was effecting this, I've removed the file but still it's getting created somehow when I try to import nltk and printing the same thing as above traceback....
The contents of the file were:
import sys
import nltk
from nltk.collocations import *
bigram_measures = nltk.collocations.BigramAssocMeasures()
trigram_measures = nltk.collocations.TrigramAssocMeasures()
# change this to read in your data
finder = BigramCollocationFinder.from_words(
nltk.corpus.genesis.words('annotation/dataset.txt'))
# only bigrams that appear 3+ times
finder.apply_freq_filter(3)
# return the 10 n-grams with the highest PMI
finder.nbest(bigram_measures.pmi, 10)
please use virtualenv, because it is not good if you update or install python packages global, because e.g. ubuntu use some special package versions for their own software and if you change something this could create a lot of problems. You can install it with:
pip install virtualenv
Here is a link with a very good introduction how to use it.
This will probably solve your problem too. I tested it also with ubuntu 16.04 by myself.
Here is my problem:
After I managed to install anaconda (having python 3.4), I apparently managed to install pybrain too. But when i use 'import pybrain' from anaconda or from the terminal too I get this error:
>>> import pybrain
Traceback (most recent call last):
File "<ipython-input-2-0fb7233d2a8c>", line 1, in <module>
import pybrain
File "//anaconda/lib/python3.4/site-packages/PyBrain-0.3-py3.4.egg/pybrain/__init__.py", line 1, in <module>
from structure.__init__ import *
ImportError: No module named 'structure'
Simply running sudo pip3 install git+https://github.com/pybrain/pybrain.git worked for me after having the same issue.
The version up on PyPi isn't Python 3 compatible.
Installing the latest commit directly using pip3 should take care of your old package (from PyPi) as well.