unable to open jupyter notebook due to accent characters - python

I just installed Anaconda, which also install jupyter. I'm unable to run jupyter notebook on windows 8.1 command, because it seems to be using the default installation path for jupyter even though I explicitly set Anaconda to install in a different path.
The default path which jupyter is trying to load is C:\Users\Vinícius\.jupyter and I set Anaconda to install at C:\Vinicius. The first path has an accent, and the second doesn't.
When I try to run jupyter notebook or jupyter notebook --notebook-dir=C:\\Temp\\ or jupyter notebook --generate-config commands, they all fail due to the first path with an accent? What should I do to fix this?
The errors for jupyter notebook or jupyter notebook --notebook-dir=C:\\Temp\\ are:
Could not decode 'C:\Users\Vin\xedcius.jupyter' for unicode trait
'config_dir' of a NotebookApp instance.

According to this github issues python 2.7 have a lot of problem with non-ascii path.
I would recommend using python 3 who have less problem with that (according to the research I've made most people said using python 3 fixed the problem).
If you still need to use 2.7 for any reasons then according to the same github issues some people managed to use 2.7 with non-ascii path by changing some files.
Here is what they said:
I found the decision: in file
C:\Path\to\Lib\site-packages\jupyter_core\paths.py you need to append
.decode(sys.getfilesystemencoding()) at the line end:
in function get_homedir:
homedir = os.path.realpath(homedir).decode(sys.getfilesystemencoding())
in function jupyter_data_dir:
appdata = os.environ.get('APPDATA', None).decode(sys.getfilesystemencoding())
After that jupyter notebook started on my Windows!
While it may fix the problem I can't say if it won't cause other problem later.
Edit: I want to add that while there may be a lot of work around to avoid this error (changing the patch of config_dir for one without non ascii character?) if you have this problem in one case you may have it with other modules or command, switching to python 3 who handle it better would, I think, be easier.

Related

cannot import name 'get_torch_default_device' from 'thinc.api' when loading en model with spacy [duplicate]

I got a problem I can't seem to figure out. The first time I imported Spacy into a Jupyter notebook I had no problems. It just imported it as I expected.
The second time I tried to import it (using a different notebook) I got:
ImportError: cannot import name 'prefer_gpu' from 'thinc.api' (C:\python-environments\nlp\lib\site-packages\thinc\api.py)
So I tried to restart the kernel and tried it again (thinking that might be the issue). That did not solve it. Also trying to run the same cell that imported Spacy in the first notebook also throws the error now after it went well the first time.
It sounds like you have an old version of Thinc somewhere; try uninstalling and reinstalling Thinc.
Another thing to check is if you're running in the right Python environment. Sometimes Jupyter notebooks pull in a different environment than the one you're expecting in non-obvious ways. There was a thread in spaCy discussions about this recently. You can run this command to check which Python executable is being used in the notebook and make sure it's the one you think it is:
import sys
print(sys.executable)
I had a similar issue, followed the git hub link, created a new environment, and installed all required packages, and it resolved my issue. I'm using Visual code, so I had to install other dependencies since VC uses this as a conda environment as a base for my code implementation

Open Jupyter in VSCode: TypeError: Cannot read properties of undefined (reading 'makeSettings')

System: MacOSX 10.15,
VSCode Version: 1.67.2,
Python Kernel Version: 3.8.13 (Conda base).
I created a new Jupyter notebook in my VSCode using command shortcut and selected the right python kernel showed above. The empty notebook page is well loaded and no error message occurred.
But when I typed and ran any code in the cell, this error message showed up below the cell.
Then I clicked the "log" link and the error log showed up and it was like this:
And hence I couldn't run any code in the notebook cell. Then I changed to another Python Kernel (3.9.12) of the same notebook, it showed the same error message:
Please give me a solution to overcome this bug.
Update: I tried to reinstall pyzmq to an older version in the canda base environment and it didn't change anything. Then I typed command jupyter --version and everything is well installed.
Update: I have searched on Github Issues of VSCode. There are two similar issues that are all caused by some extensions, one is called "Gitduck"(now renamed "duckly"), the other is "nur.Script". The link to these issues are here:
Cannot read property 'makeSettings' of undefined #834
Cannot read property 'makeSettings' of undefined #128458
But unfortunately, I never have installed any of these extensions in my VSCode. So it may be caused by a similar extension but I still don't know the name.
Finally, I use the command code --list-extensions to list all my installed extensions here, maybe helpful for filtering which extension is the bad guy:
Final Update: Today (05/31) I opened VSCode and tentatively created an empty Jupyter notebook, and this problem has gone away. I have done nothing, maybe VSCode's auto-update has solved this problem. Case closed.
You can try reinstalling the pyzmq module.
pip uninstall pyzmq
pip install pyzmq==19.0.2
Hope this helps you.

ImportError loading spacy in jupyter notebook

I got a problem I can't seem to figure out. The first time I imported Spacy into a Jupyter notebook I had no problems. It just imported it as I expected.
The second time I tried to import it (using a different notebook) I got:
ImportError: cannot import name 'prefer_gpu' from 'thinc.api' (C:\python-environments\nlp\lib\site-packages\thinc\api.py)
So I tried to restart the kernel and tried it again (thinking that might be the issue). That did not solve it. Also trying to run the same cell that imported Spacy in the first notebook also throws the error now after it went well the first time.
It sounds like you have an old version of Thinc somewhere; try uninstalling and reinstalling Thinc.
Another thing to check is if you're running in the right Python environment. Sometimes Jupyter notebooks pull in a different environment than the one you're expecting in non-obvious ways. There was a thread in spaCy discussions about this recently. You can run this command to check which Python executable is being used in the notebook and make sure it's the one you think it is:
import sys
print(sys.executable)
I had a similar issue, followed the git hub link, created a new environment, and installed all required packages, and it resolved my issue. I'm using Visual code, so I had to install other dependencies since VC uses this as a conda environment as a base for my code implementation

Anaconda Import error, circular import error

I'm trying to use anaconda to setup an environment for jupyter notebook. It's not going well... I've got everything working without anaconda (just on the normal windows terminal). On Anaconda terminal however, whenever I try to install jupyter notebook it gives me an import error (could be circular issue it says). I also cannot open anaconda navigator through either the app or command prompt. I have followed documentation and this video. Please any help would be greatly appreciated, I am going to try uninstalling anaconda and then seeing if that gets me any results...
What is the library's name are you trying to import? I am guessing 'jupyter'
Checking your local filenames might be useful. If any files in your project involve the word that is in the import statement, that could prevent the actual jupyter library being imported.
I had the same problem, tried to import numpy and got a similar error. Turns out that I had a file called 'numpy.py' in my project directory. I renamed it and solved the problem.
Try to reset pyzmq by doing the following:
pip uninstall pyzmq
pip install pyzmq

"tput: Unknown terminal 'emacs'" messages when using PyCharm / iPython console on Windows

I am using PyCharm with iPython on Windows. The only Python I have installed on the box is the latest Anaconda distribution, Python 3.4 flavor.
Very often, while using the console, I get numerous instances of the following warning message:
tput: unknown terminal "emacs"
This is mixed in with the normal output. Has anyone else experienced and/or fixed this? I have dug through both the iPython and PyCharm documentation and have not found anything related.
Did you install anything new recently?
Check your path for anything "unixy", for example I removed ...\Git\bin from my path and it solved the problem for me.

Categories