I have develop a simple program using dash plotly in spyder but it showing me the following error.
import dash
import dash_core_components as dcc
import dash_html_components as html
app = dash.Dash()
app.layout = html.Div(
html.H1(children='Hello Dash')
)
if __name__ == '__main__':
app.run_server(debug=True)
but it showing me the following error.
Running on http://127.0.0.1:8050/
Debugger PIN: 870-923-677
Traceback (most recent call last):
File "<ipython-input-13-3c5b23764cd8>", line 5, in <module>
app.run_server(debug=True)
File "C:\Users\Hussnain\Anaconda3\lib\site-packages\dash\dash.py", line 1503, in run_server
self.server.run(port=port, debug=debug, **flask_run_options)
File "C:\Users\Hussnain\Anaconda3\lib\site-packages\flask\app.py", line 938, in run
cli.show_server_banner(self.env, self.debug, self.name, False)
File "C:\Users\Hussnain\Anaconda3\lib\site-packages\flask\cli.py", line 629, in show_server_banner
click.echo(message)
File "C:\Users\Hussnain\Anaconda3\lib\site-packages\click\utils.py", line 259, in echo
file.write(message)
UnsupportedOperation: not writable
Spyder has some conflicts using Debug=True. Please run your code inside Visual Studio Code.
For my system: Your code is running fine.
Please tell us if this software swap solved your problem. If not, I will provide further assistance. :)
Related
from medpy.io import load
import SimpleITK
import vtk
image_data, image_header = load('/Users/N01-T2.mha')
print image_data.shape
And the error is:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/wuzhenglin/anaconda/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 880, in runfile
execfile(filename, namespace)
File "/Users/wuzhenglin/anaconda/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 94, in execfile
builtins.execfile(filename, *where)
File "/Users/wuzhenglin/Python_nice/SAL_LUNG/test.py", line 140, in <module>
changeage()
File "/Users/wuzhenglin/Python_nice/SAL_LUNG/test.py", line 42, in changeage
image_data, image_header = load('/Users/wuzhenglin/Python_nice/SAL_BRAIN/brain_healthy_dataset/Normal001-T2.mha')
File "/Users/wuzhenglin/anaconda/lib/python2.7/site-packages/medpy/io/load.py", line 201, in load
raise err
medpy.core.exceptions.ImageLoadingError: Failes to load image /Users/wuzhenglin/Python_nice/SAL_BRAIN/brain_healthy_dataset/Normal001-T2.mha as
Itk/Vtk MetaImage (.mhd, .mha/.raw). Reason signaled by third-party module:
'LazyITKModule' object has no attribute 'AnalyzeImageIO'
I want to deal with .mha image, but it doesn't work.
I have installed medpy, itk and vtk.
I have searched on Google, but there is not related answer to this problem.
Does the same error occur without the import SimpleITK line? I don't think that is relevant to producing this error.
ITK for Python and SimpleITK are two separate Python packages which provide different interfaces to ITK. The error you are seeing is lated to ITK for Python, or the itk package on PyPi. Where did you itk install come from. Can you run a simple program like this, with your install?
#!/usr/bin/env python
import itk
pixelType = itk.UC
imageType = itk.Image[pixelType, 2]
readerType = itk.ImageFileReader[imageType]
I have been working on a web scraping program and it has recently just stopped working and is giving me the following error.
Traceback (most recent call last):
File "C:/Users/Bob/Desktop/test 3.5.py", line 7, in <module>
with open(saveDB,'rb') as f:
TypeError: invalid file: WindowsPath('Z:/project1/MasterWellDB.txt')
Where Z: is a network drive, but I have also moved the file locally and the error still exists.
I have tried multiple python versions, uninstalled and reinstalled visual studio multiple times and I am still clueless.
Here is my code:
from pathlib import Path
import pickle
# Opening well database
saveDB = Path(r"Z:\project1\MasterWellDB.txt")
#open picked DB if avaiable else remake database
if saveDB.exists():
with open(saveDB,'rb') as f:
wells = pickle.load(f)
print('success!')
Any help would be greatly appreciated. Thanks!
Hi text mining champions,
I'm using Anaconda with NLTK v3.2 on Windows 10.(client's environment)
When I try to POS tag, I keep getting a URLLIB2 error:
URLError: <urlopen error unknown url type: c>
It seems urllib2 is unable to recognize windows paths? How can I work around this?
The command is simple as:
nltk.pos_tag(nltk.word_tokenize("Hello World"))
edit:
There is a duplicate question, however I think the answers obtained here by manan and alvas are a better fix.
EDITED
This issue has been resolved from NLTK v3.2.1. Upgrading your NLTK version would resolve the issue, e.g. pip install -U nltk.
I faced the same issue and the error encountered was as follows;
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\nltk-3.2-py2.7.egg\nltk\tag\__init__.py", line 110, in pos_tag
tagger = PerceptronTagger()
File "C:\Python27\lib\site-packages\nltk-3.2-py2.7.egg\nltk\tag\perceptron.py", line 141, in __init__
self.load(AP_MODEL_LOC)
File "C:\Python27\lib\site-packages\nltk-3.2-py2.7.egg\nltk\tag\perceptron.py", line 209, in load
self.model.weights, self.tagdict, self.classes = load(loc)
File "C:\Python27\lib\site-packages\nltk-3.2-py2.7.egg\nltk\data.py", line 801, in load
opened_resource = _open(resource_url)
File "C:\Python27\lib\site-packages\nltk-3.2-py2.7.egg\nltk\data.py", line 924, in _open
return urlopen(resource_url)
File "C:\Python27\lib\urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "C:\Python27\lib\urllib2.py", line 391, in open
response = self._open(req, data)
File "C:\Python27\lib\urllib2.py", line 414, in _open
'unknown_open', req)
File "C:\Python27\lib\urllib2.py", line 369, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 1206, in unknown_open
raise URLError('unknown url type: %s' % type)
urllib2.URLError: <urlopen error unknown url type: c>
The URLError that you mentioned was due to a bug in the perceptron.py file within the NLTK library for Windows.
In my machine, the file is at this location
C:\Python27\Lib\site-packages\nltk-3.2-py2.7.egg\nltk\tag\perceptron.py
(Basically look at an equivalent location within yours wherever you have the Python27 folder)
The bug was basically in the code to find the corresponding location for the averaged_perceptron_tagger within your machine. One can have a look at the line 801 and 924 mentioned in the data.py file regarding this.
I think the NLTK developer community recently fixed this bug in the code. Have a look at this commit made to their code a few days back.
https://github.com/nltk/nltk/commit/d3de14e58215beebdccc7b76c044109f6197d1d9#diff-26b258372e0d13c2543de8dbb1841252
The snippet where the change was made is as follows;
self.tagdict = {}
self.classes = set()
if load:
AP_MODEL_LOC = 'file:'+str(find('taggers/averaged_perceptron_tagger/'+PICKLE))
self.load(AP_MODEL_LOC)
# Initially it was:AP_MODEL_LOC = str(find('taggers/averaged_perceptron_tagger/'+PICKLE))
def tag(self, tokens):
Updating the file to the most recent commit worked for me and was able to use the nltk.pos_tag command. I believe this would resolve your problem as well (assuming you have everything else set up).
EDITED
This issue has been resolved from NLTK v3.2.1. Please upgrade your NLTK!
First read #MananVyas answer for the why:
https://stackoverflow.com/a/35902494/610569
Here's the how, without downgrading to NLTK v3.1, using NLTK 3.2, you can use this "hack":
>>> from nltk.tag import PerceptronTagger
>>> from nltk.data import find
>>> PICKLE = "averaged_perceptron_tagger.pickle"
>>> AP_MODEL_LOC = 'file:'+str(find('taggers/averaged_perceptron_tagger/'+PICKLE))
>>> tagger = PerceptronTagger(load=False)
>>> tagger.load(AP_MODEL_LOC)
>>> pos_tag = tagger.tag
>>> pos_tag('The quick brown fox jumps over the lazy dog'.split())
[('The', 'DT'), ('quick', 'JJ'), ('brown', 'NN'), ('fox', 'NN'), ('jumps', 'VBZ'), ('over', 'IN'), ('the', 'DT'), ('lazy', 'JJ'), ('dog', 'NN')]
I faced the same issue a while back.
Solution:
nltk.download('averaged_perceptron_tagger')
I have been having all kinds of problems getting Windmill setup and installed. I thought I finally got it setup, but now when I try to just run windmill, I get the following errors. Any help is appreciated.
c:\Python33\Scripts>windmill firefox http://www.google.com Traceback
(most recent call last): File
"c:\Python33\Scripts\windmill-script.py", line 9, in
load_entry_point('windmill==1.6', 'console_scripts', 'windmill')() File
"C:\Python33\lib\site-packages\distribute-0.6.49-py3.3.egg\pkg_resources.
py", line 345, in load_entry_point
return get_distribution(dist).load_entry_point(group, name) File "C:\Python33\lib\site-packages\distribute-0.6.49-py3.3.egg\pkg_resources.
py", line 2382, in load_entry_point
return ep.load() File "C:\Python33\lib\site-packages\distribute-0.6.49-py3.3.egg\pkg_resources.
py", line 2088, in load
entry = import(self.module_name, globals(),globals(), ['name']) File
"C:\Python33\lib\site-packages\windmill-1.6-py3.3.egg\windmill__init__.p
y", line 17, in
import bin, browser, server, conf, tools, sys ImportError: No module named 'bin'
I had the same issue; Windmill doesn't work with Python 3.x. To fix the problem install Python 2.x
Using cx_freeze under ubuntu 12.04. The generation of the package is
done without any errors but when I try to run the package as a
standalone, I get the following error:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/cx_Freeze/initscripts /Console.py",
line 27, in <module>
exec code in m.__dict__
m m File "Setup_cx_freeze.py", line 3, in <module>
File "/usr/local/lib/python2.7/dist-packages/cx_Freeze/__init__.py",
line 4, in <module>
from cx_Freeze.dist import *
File "/usr/local/lib/python2.7/dist-packages/cx_Freeze/dist.py",
line 3, in <module>
import distutils.command.install
File "/usr/lib/python2.7/distutils/command/install.py", line 21, in <module>
from site import USER_BASE
File "/usr/lib/python2.7/site.py", line 562, in <module>
main()
File "/usr/lib/python2.7/site.py", line 540, in main
abs__file__()
File "/usr/lib/python2.7/site.py", line 100, in abs__file__
m.__file__ = os.path.abspath(m.__file__)
File "/usr/lib/python2.7/email/__init__.py", line 79, in __getattr__
__import__(self.__name__)
ImportError: No module named image
I think what to focus on is the last sentence. "ImportError: No module named image."
The application runs without any problems in pure python environment
So why do I get the Error when running it as a "freeze" package? The
fault is somehow introduced when generating the freeze-package.
I ended up fixing this by explicitly including the package "email.mime" in the setup.py script build exe options.
Missing 'image' is just first part of the problem. Try to add this to your code:
from email.mime.image import MIMEImage
from email.mime.audio import MIMEAudio
from email.mime.message import MIMEMessage
This resolved problems with 'image', 'audio' and 'message'.
Resolved this by installing Python Imaging Library: http://www.pythonware.com/products/pil/
1) python setup.py build
2) sudo python setup.py install