I have tried every thing right from conda-clean, re-installing anaconda sevral times, even cleaned windows registry to completely remove anaconda before re-installation. Every time I am trying to launch jupyter notebook a pop-up opens with msg
(Traceback (most recent call last): File "C:\anaconda\Scripts\jupyter-notebook-script.py", line 6, in from notebook.notebookapp import main File "C:\anaconda\lib\site-packages\notebook\notebookapp.py", line 83, in from .services.contents.manager import ContentsManager File "C:\anaconda\lib\site-packages\notebook\services\contents\manager.py", line 17, in from nbformat import sign, validate as validate_nb, ValidationError File "C:\anaconda\lib\site-packages\nbformat__init__.py", line 33, in from .validator import validate, ValidationError File "C:\anaconda\lib\site-packages\nbformat\validator.py", line 12, in from jsonschema import ValidationError File "C:\anaconda\lib\site-packages\jsonschema__init__.py", line 12, in from jsonschema.exceptions import ( File "C:\anaconda\lib\site-packages\jsonschema\exceptions.py", line 141, in #attr.s(hash=True) AttributeError: module 'attr' has no attribute 's')
Kindly help for the same.
Related
I did an application with Tkinter and this has a function based in spacy. When a built the executable file using Pyinstaller I ran pyinstaller simple.py --additional-hooks-dir=.. My file hook collect the necessary packages also the pre-trained language spacy model es_cores_news_sm with the follow code:
from PyInstaller.utils.hooks import collect_all
# ----------------------------- SPACY -----------------------------
data = collect_all("spacy")
datas = data[0]
binaries = data[1]
hiddenimports = data[2]
from PyInstaller.utils.hooks import collect_data_files
datas += collect_data_files("es_core_news_sm")
The executable was create and open well. When I use the function based in spacy we obtain the follow error:
Exception in Tkinter callback
Traceback (most recent call last):
File "tkinter/__init__.py", line 1705, in __call__
File "simple.py", line 152, in calcular
File "predictors.py", line 16, in cash_pred
File "utils.py", line 41, in clean_text
File "spacy/__init__.py", line 47, in load
File "spacy/util.py", line 329, in load_model
OSError: [E050] Can't find model 'es_core_news_sm'. It doesn't seem to be a Python package or a valid path to a data directory.
Originally, I installed in my pip environment the pre-trained model with python -m spacy download es_core_news_sm. How can I collect well this pre-trained model well in Pyinstaller?
The script is be able to run a software called PoiwerFctory externally by Python as follows:
#add powerfactory.pyd path to python path
import sys
sys.path.append("C:\\Program Files\\DIgSILENT\\PowerFactory 2017
SP2\\Python\\3.6")
#import powerfactory module
import powerfactory
#start powerfactory module in unattended mode (engine mode)
app=powerfactory.GetApplication()
#get the user
user=app.GetCurrentUser()
#active project
project=app.ActivateProject('Python Test') #active project "Python Test"
prj=app.GetActiveProject #returns the actived project
#run python code below
ldf=app.GetFromStudyCase('ComLdf') #caling loadflow command object
ldf.Execute() #executing the load flow command
#get the list of lines contained in the project
Lines=app.GetCalcRelevantObjects('*.ElmLne') #returns all relevant objects,
i.e. all lines
for line in Lines: #get each element out of list
name=line.loc_name #get name of the line
value=line.GetAttribute('c:loading') # return the value of elements
#Print the results
print('Loading of the line: %s = %.2f'%(name,value))
When the above code first time executed in Spyder, it will show proper resutls. However, if re-executing the script again, the following error is appeared:
Reloaded modules: powerfactory
Traceback (most recent call last):
File "<ipython-input-9-ae989570f05f>", line 1, in <module>
runfile('C:/Users/zd1n14/Desktop/Python Test/Call Digsilent in
Python.py', wdir='C:/Users/zd1n14/Desktop/Python Test')
File "C:\ProgramData\Anaconda3\lib\site-
packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "C:\ProgramData\Anaconda3\lib\site-
packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/zd1n14/Desktop/Python Test/Call Digsilent in Python.py",
line 12, in <module>
user=app.GetCurrentUser()
RuntimeError: 'powerfactory.Application' already deleted
Referred to How can I exit powerfactory using Python in Unattended mode?, this may because of PowerFactory in still running. And the only way which has been found so far is to re-start the Spyder and execute the script again, this is so inefficiency that if I want to re-write the code and debugging it.
It would be so much appropriated that if anyone could give me some advice for such problem.
I ran into the same Problem. Python is still connected to powerfactory and gives the Error if you try to connect again. What basicly worked for me was to kill the instance on the end of your skript with
del app
another idea during debugging could be:
try:
# Do something in your skript
finally:
del app
So the killing of the instance happens in any case.
The way to solve this is to reload the powerfacotry module by adding:
if __name__ == "__main__":
before import powerfacory.
The reason behind may referred to: What does if __name__ == "__main__": do?.
I want to use a python engine in knitr. I have installed a module named undaqTools for python 2.7 using Anaconda3. If I run the following in IPython, it works fine:
from undaqTools import Daq
I tried the same in a python code chunk but that didn't work. I found a relevant question in SO, linked here. So, I first did following in IPython:
import undaqTools
import os
path = os.path.dirname(undaqTools.__file__)
path
Out[5]: 'C:\\Anaconda3\\envs\\py27\\lib\\site-packages\\undaqtools-0.2.3-py2.7.egg\\undaqTools'
Therefore, I created a new chunk in knitr and did following:
```{python}
import sys
sys.path.append('C:/Anaconda3/envs/py27/lib/site-packages/undaqtools-0.2.3-py2.7.egg/')
from undaqTools import Daq
```
But that gives me following error:
Traceback (most recent call last):
File "C:\Users\durraniu\AppData\Local\Temp\RtmpGOOQHX\chunk-code195061e728da.", line 13, in <module>
from undaqTools import Daq
File "C:\Anaconda3\envs\py27\lib\site-packages\undaqtools-0.2.3-py2.7.egg\undaqTools\__init__.py", line 5, in <module>
ImportError: No module named 'daq'
How can I fix this?
According to the directions of Openstack Official Heat/Plugins wiki https://wiki.openstack.org/wiki/Heat/Plugins, we only need "To install a plugin, copy the Python modules to one of the configured plugin directories. Note that heat-engine must be restarted after this in order to load the new plugins.". But I hit the following error messages after I restart heat-engine..
[root#cs14 heat]# heat-engine
2015-05-04 06:02:09.774 20839 WARNING heat.common.config [-] HT-A65A0DF The "instance_user" option in heat.conf is deprecated and will be removed in the Juno release.
[05/04/2015 06:02:10 EDT]heatCRITICAL : ImportError: No module named my_heat_plugin.client
Traceback (most recent call last):
File "/usr/bin/heat-engine", line 67, in <module>
srv = engine.EngineService(cfg.CONF.host, rpc_api.ENGINE_TOPIC)
File "/usr/lib/python2.6/site-packages/heat/engine/service.py", line 288, in __init__
resources.initialise()
File "/usr/lib/python2.6/site-packages/heat/engine/resources/__init__.py", line 44, in initialise
_load_global_environment(global_env)
File "/usr/lib/python2.6/site-packages/heat/engine/resources/__init__.py", line 49, in _load_global_environment
_load_global_resources(env)
File "/usr/lib/python2.6/site-packages/heat/engine/resources/__init__.py", line 54, in _load_global_resources
manager = plugin_manager.PluginManager(__name__)
File "/usr/lib/python2.6/site-packages/heat/engine/plugin_manager.py", line 58, in __init__
self.modules = list(modules())
File "/usr/lib/python2.6/site-packages/heat/common/plugin_loader.py", line 91, in load_modules
module = _import_module(importer, module_name, package)
File "/usr/lib/python2.6/site-packages/heat/common/plugin_loader.py", line 72, in _import_module
module = loader.load_module(module_name)
File "/usr/lib64/python2.6/pkgutil.py", line 238, in load_module
mod = imp.load_module(fullname, self.file, self.filename, self.etc)
File "/usr/lib/heat/abc_heat_plugin/resources/abc/abc_server.py", line 24, in <module>
from abc_heat_plugin.client import constants as const
ImportError: No module named abc_heat_plugin.client
To solve this problem, I've figured out two ways which are workable.
Method 1. copy abc_heat_plugin to /usr/lib/python2.6/site-packages and restart heat-engine
Method 2. use .pth file.
1) Create a file /usr/lib/python2.6/site-packages/.pth with the following three lines (no need to do this if it exists)
/usr/lib/heat
/usr/lib/heat/abc_heat_plugin
/usr/lib/heat/abc_heat_plugin/client
2) copy plugin "my_heat_plugin" to /usr/lib/heat
3) restart heat service
BUT both ways have to do more than the official guide, so I wonder whether I missed anything important. Any suggestions? Thanks.
(BTW, my_heat_plugin is working well.)
I think the basic idea is that you drop the resource in /usr/lib/heat, but any modules or packages that are used by the resource must be installed the usual way. You sort of did that manually by moving the files to site-packages.
Take a look at any of the plugins in heat/contrib for example. There are a few that have dependencies such as clients to other OpenStack services, and in all cases the assumption is made that those clients were installed separately.
So if you can, just create a setup.py for your client package, and install that separately from the heat plugin.
I am learning python and am just getting into pandas. I am already familiar with R. I would like to be able to create a data frame in python and then somehow get it into R.
Could I do this somehow by writing the file to a CSV and then opening it into R? If so, where should I go to learn how to do this?
I found this website: http://pandas.pydata.org/pandas-docs/dev/r_interface.html that seems to be one solution - it uses rpy2 as a link between python and R. It is unclear to me, though, how the data frame actually gets opened up in R.
But I couldn't get that far because I had an error when trying to execute this code:
import pandas.rpy.common as com
I get this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/pandas/rpy/__init__.py", line 2, in <module>
from common import importr, r, load_data
File "/Library/Python/2.7/site-packages/pandas/rpy/common.py", line 12, in <module>
from rpy2.robjects.packages import importr
File "rpy2.py", line 1, in <module>
import pandas.rpy.common as com
AttributeError: 'module' object has no attribute 'rpy'
I installed rpy2 using easy_install. It seems to be the latest version.
What should I do?