Setting up Hydrogen and Atom with Anaconda managing python installation - python-3.x

I have added my python 3 executable to the system PATH (against the advice of Anaconda) to try and get Hydrogen (and really any Atom extension/plugin) to run lines or blocks of code in Atom. The 'scripts' atom plugin appears to work (I select some code and enter ctrl-shift-b), but I'd love to use more of the features in Hydrogen. When I execute (for example):
print('hello world')
I get the following error:
Python 3
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec)
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals)
File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py", line 15, in from ipykernel import kernelapp as app
File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel__init__.py", line 2, in from .connect import
File "C:\ProgramData\Anaconda3\lib\site-packages\ipykernel\connect.py", line 18, in import jupyter_client File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client__init__.py", line 4, in from .connect import
File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 23, in import zmq
File "C:\ProgramData\Anaconda3\lib\site-packages\zmq__init__.py", line 47, in from zmq import backend
File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\backend__init__.py", line 40, in reraise(*exc_info)
File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise raise value
File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\backend__init__.py", line 27, in _ns = select_backend(first)
File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\backend\select.py", line 27, in select_backend mod = import(name, fromlist=public_api)
File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\backend\cython__init__.py", line 6, in from . import (constants, error, message, context,
ImportError: DLL load failed: The specified module could not be found.
I have reinstalled the package, I've tried using the Anaconda power shell and normal prompt to install and load Atom. My only guess is that its having trouble launching a kernel, or am I supposed to launch one and then connect?
End goal:
run code block and it works.

To use a Conda env as a kernel in Hydrogen you must register the env using ipykernel, e.g.,
conda activate myenv
python -m ipykernel install --user
This creates an entry for the kernel in a default user-level location that is generically visible to any Jupyter instances run by the user (such as Hydrogen). It is recommended to also include a --name NAME flag to distinguish your different envs. Please refer to the python -m ipykernel install -h for more options.
Also, note that the minimum requirement for using a Conda env as a kernel is to install ipykernel. And, yeah, clean up the PATH so that it conforms to Conda best practices - there should be no need for manually editing.

Related

Python 3.11 - creating a virtual Env - Frozen runpy

After following a thread on how to fix the pip SLL issue, now this:
So far I have spent more time fixing environments than actual training.
I am using an Oracle appliance with Linux server 7 on it.
Has anyone seen this error and know a fix for it, please?
[oracle#localhost myProjects]$ python3 -V
Python 3.11.0a4
[oracle#localhost myProjects]$ python3 -m venv env
Traceback (most recent call last):
File "<frozen runpy>", line 189, in _run_module_as_main
File "<frozen runpy>", line 148, in _get_module_details
File "<frozen runpy>", line 112, in _get_module_details
File "/usr/local/lib/python3.11/venv/__init__.py", line 7, in <module>
import logging
^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/logging/__init__.py", line 26, in <module>
import sys, os, time, io, re, traceback, warnings, weakref, collections.abc
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/re/__init__.py", line 125, in <module>
from . import _compiler, _parser
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/re/_compiler.py", line 18, in <module>
assert _sre.MAGIC == MAGIC, "SRE module mismatch"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: SRE module mismatch
There are a couple of possible solutions on a Chinese blog platform I haven't met before. One by weixin_42424046 and one by jacke121.
Set module load apps/python/3.6.3/gnu in .bashrc, and source .bashrc after saving, but still report the same error when running python. the solution is
vi .bash_profile
Add at the end of the file
export PYTHON_HOME=/g1/app/apps/python/3.6.3/gnu/
export PATH=$PYTHON_HOME/bin:$PATH
After saving, source .bash_profile
Re-run python problem solved.
This problem is caused by the environment is 32-bit python
Change the environment to a 64 python environment
These links don't answer the exact question but can give you some ideas for further research.

cx_Freeze ConfigError: No file named C:\Python\Scripts\cxfreeze.exe\__main__.py (for module __main__)

I would like to create a .exe file of a file named ZCasinoinsulte.py located in C:\Python\Scripts. Moreoever, every time I execute cxfreeze ZCasinoinsulte.py it never works and tells me it does not find _main_.py in cxfreeze.exe.
Specs: I have python 3.9.1 on Windows 10 64bit.
I have installed cx_Freeze-6.5.1 with whl.
It does create an exe file, but it opens and shuts down instantly (even though I put os.system("pause") in ZCasinoinsulte.py).
old code
Any help would be appreciated :D
Edit: I have used the cxfreeze version 6.4.2 and the code runs better without errors. But the exe file closes as soon as I clic on it.
Here is my pip list traceback:
C:\Users\Hmili>pip list
Package Version
------------------ -------
cx-Freeze 6.4.2
importlib-metadata 3.4.0
pip 20.3.3
setuptools 49.2.1
zipp 3.4.0
Here is the traceback when I execute the exe file from cmd:
C:\Python\Mes fichiers python\dist>ZCasinoinsulte.exe
Traceback (most recent call last):
File "c:\python\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 41, in run
module.run()
File "c:\python\lib\site-packages\cx_Freeze\initscripts\Console.py", line 36, in run
exec(code, m.__dict__)
File "ZCasinoinsulte.py", line 3, in <module>
File "c:\python\lib\site-packages\cx_Freeze\__init__.py", line 1, in <module>
import setuptools
File "c:\python\lib\site-packages\setuptools\__init__.py", line 24, in <module>
from setuptools.depends import Require
File "c:\python\lib\site-packages\setuptools\depends.py", line 6, in <module>
from .py33compat import Bytecode
File "c:\python\lib\site-packages\setuptools\py33compat.py", line 11, in <module>
from setuptools.extern.six.moves import html_parser
File "c:\python\lib\site-packages\setuptools\_vendor\six.py", line 92, in __get__
result = self._resolve()
File "c:\python\lib\site-packages\setuptools\_vendor\six.py", line 115, in _resolve
return _import_module(self.mod)
File "c:\python\lib\site-packages\setuptools\_vendor\six.py", line 82, in _import_module
__import__(name)
ModuleNotFoundError: No module named 'html.parser'
Here are the first ten lines of ZCasinoinsulte.py:
# -*-coding:Latin-1 -*
import os,time
from cx_Freeze import setup, Executable
from random import randrange
argent=3000
while argent>0:
condition1=0
condition2=0
argent=int(argent)
How do I resolve this? (Thanks for the help by the way :) )
I reverted cx_Freeze back to version 6.4.2, seemed to compile fine after that
pip install --upgrade cx-Freeze==6.4.2
Seems to be a bug or something.
First I downgraded pip as James Mackey advised me. The code ran properly and created an exe file. So the first issue was a comptability one.
Moreover, the exe file created crashed instantly when executed. From the traceback of the execution of ZCasinoinsulte.exe with cmd, James Mackey figured the third line of ZCasinoinsulte.py had an error related to it.
The third line of ZCasinoinsulte.py was:
from cx_Freeze import setup, Executable
I erased this line as it has nothing to do with the actual code.
I opened cmd and executed again the command: cxfreeze ZCasinoinsulte.py. The exe file now functions properly.

How to solve "jupyter_client.kernelspec.NoSuchKernel: No such kernel named iqsharp" in python?

I was trying to print hello world in Microsoft's Q#.
When I ran the code It's shows like this.
Even I installed the package. I don't know where the problem is.
I think it's in jupyter notebook's permission or something.
Thanks for your help.
Here is my simple code
import qsharp
from HelloWorld import SayHello
SayHello.simulate()
Here is my output
File "d:\Program Files\Quantum Projects\hello_quantum.py", line 1, in <module>
import qsharp
File "C:\Users\ELCOT\AppData\Local\Programs\Python\Python36\lib\site-packages\qsharp\__init__.py", line 119, in <module>
client = _start_client()
File "C:\Users\ELCOT\AppData\Local\Programs\Python\Python36\lib\site-packages\qsharp\clients\__init__.py", line 28, in _start_client
client.start()
File "C:\Users\ELCOT\AppData\Local\Programs\Python\Python36\lib\site-packages\qsharp\clients\iqsharp.py", line 75, in start
self.kernel_manager.start_kernel(extra_arguments=["--user-agent", f"qsharp.py{user_agent_extra}"])
File "C:\Users\ELCOT\AppData\Local\Programs\Python\Python36\lib\site-packages\jupyter_client\manager.py", line 246, in start_kernel
kernel_cmd = self.format_kernel_cmd(extra_arguments=extra_arguments)
File "C:\Users\ELCOT\AppData\Local\Programs\Python\Python36\lib\site-packages\jupyter_client\manager.py", line 170, in format_kernel_cmd
cmd = self.kernel_spec.argv + extra_arguments
File "C:\Users\ELCOT\AppData\Local\Programs\Python\Python36\lib\site-packages\jupyter_client\manager.py", line 82, in kernel_spec
self._kernel_spec = self.kernel_spec_manager.get_kernel_spec(self.kernel_name)
File "C:\Users\ELCOT\AppData\Local\Programs\Python\Python36\lib\site-packages\jupyter_client\kernelspec.py", line 236, in get_kernel_spec
raise NoSuchKernel(kernel_name)
jupyter_client.kernelspec.NoSuchKernel: No such kernel named iqsharp
I was running into the same issue when setting my conda environment from a script:
#!/bin/sh
. $CONDA_PREFIX/etc/profile.d/conda.sh
# assumes you followed this doc and have run:
# conda create -n qsharp-env -c quantum-engineering qsharp notebook
conda activate qsharp-env
I solved it by installing IQ# as instructed by the documentation (slightly different from Ryan Shaffer's comment):
dotnet tool install -g Microsoft.Quantum.IQSharp
dotnet iqsharp install
I was then able to run python -c "import qsharp" and more complex Python programs.

the yowsup library does not work when I try to register

I installed the next packages in my raspberry with pip3:
-python-axolotl
-protobuf
-six
-argparse
-readline
-pillow
-tqdm
-requests
-pycrypto
-blinker
Next I installed yowsup with
pip3 install yowsup
So, I download a repository, https://github.com/danielcardeenas/whatsapp-framework, (today is 2019-May-17), I live in Colombian, so I intent send the registration with:
yowsup-cli registration --requestcode sms --phone 57317509xxx --cc 57 -E android
I installed the next packages in my raspberry with pip3:
-python-axolotl
-protobuf
-six
-argparse
-readline
-pillow
-tqdm
-requests
-yowsup
-pycrypto
-blinker
next, I download a repository, https://github.com/danielcardeenas/whatsapp-framework, (today is 2019-May-17), I live in Colombian, so I intent send the registration with:
yowsup-cli registration --requestcode sms --phone 57317509xxx --cc 57 -E android
but the console print a error:
Traceback (most recent call last):
File "/usr/local/bin/yowsup-cli", line 4, in
import('pkg_resources').run_script('yowsup2==2.5.2', 'yowsup-cli')
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 739, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 1494, in run_script
exec(code, namespace, namespace)
File "/usr/local/lib/python3.5/dist-packages/yowsup2-2.5.2-py3.5.egg/EGG-INFO/scripts/yowsup-cli", line 368, in
if not parser.process():
File "/usr/local/lib/python3.5/dist-packages/yowsup2-2.5.2-py3.5.egg/EGG-INFO/scripts/yowsup-cli", line 189, in process
self.handleRequestCode(self.args["requestcode"], config)
File "/usr/local/lib/python3.5/dist-packages/yowsup2-2.5.2-py3.5.egg/EGG-INFO/scripts/yowsup-cli", line 198, in handleRequestCode
from yowsup.registration import WACodeRequest
File "/usr/local/lib/python3.5/dist-packages/yowsup/registration/init.py", line 1, in
from .coderequest import WACodeRequest
File "/usr/local/lib/python3.5/dist-packages/yowsup/registration/coderequest.py", line 1, in
from yowsup.common.http.warequest import WARequest
File "/usr/local/lib/python3.5/dist-packages/yowsup/common/http/init.py", line 2, in
from .warequest import WARequest
File "/usr/local/lib/python3.5/dist-packages/yowsup/common/http/warequest.py", line 8, in
from yowsup.common.tools import WATools
File "/usr/local/lib/python3.5/dist-packages/yowsup/common/tools.py", line 10, in
from consonance.structs.keypair import KeyPair
File "/usr/local/lib/python3.5/dist-packages/consonance/structs/keypair.py", line 4, in
from dissononce.dh.x25519.x25519 import X25519DH
File "/usr/local/lib/python3.5/dist-packages/dissononce/dh/x25519/x25519.py", line 1, in
from cryptography.hazmat.primitives.asymmetric import x25519
ImportError: cannot import name 'x25519'
Had a similar issue
The problem is not with yowsup, but with its dependencies (so it couldn't import: x25519) and concretely with the cryptography library.
The following commands might help you solve it but check while installing that dependencies are solved, because there seems to be a lot of them that have to be manually solved:
pip3 install cryptography --force-reinstall
pip3 install yowsup --force-reinstall
Other commands you may have to use to solve dependencies:
pip3 install python-axolotl-curve25519
pip3 install six==1.10
Hope to at least have pointed in the right direction!

install issue with python - spacy package in anaconda environment

I'm attempting to follow this tutorial to install the natural language processing package spaCy into a python 3 anaconda environment, windows 8
I opened console, cd-ed to my site-packages folder, activated environment, pip-ed for install, everything seemed fine except I couldn't run the second command here
$ pip install spacy
$ python -m spacy.en.download
Now I can successfully load the package but when I run the second line below, I get the following error
>>> from spacy.en import English #this works
>>> nlp = English() #this doesn't
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\garrett\Anaconda\envs\py3k\lib\site-packages\spacy\en\__init__.py", line 64, in __init__
get_lex_props=get_lex_props)
File "spacy/vocab.pyx", line 42, in spacy.vocab.Vocab.__init__ (spacy/vocab.cpp:2216)
OSError: Directory C:\Users\garrett\Anaconda\envs\py3k\lib\site-packages\spacy\en\data\vocab not found -- cannot load Vocab.
I think that it is due to the fact that I couldn't run python -m spacy.en.download
Can anyone give me an idea of what python -m spacy.en.download is supposed to be doing?
Can anyone provide a walkthrough for how to get spaCy installed in an anaconda environment?
here's the error I get after setting the directory, activating python env, running command. The first several times I tried, my spyder editor went unresponsive and I killed the console, the most recent time I got this error
$ cd C:\Users\garrett\Anaconda\envs\py3k\Lib\site-packages
$ C:\Users\garrett\Anaconda\envs\py3k\Lib\site-packages>activate py3k
$ [py3k] C:\Users\garrett\Anaconda\envs\py3k\Lib\site-packages>python -m spacy.en.download
Moving existing dir C:\Users\garrett\Anaconda\envs\py3k\Lib\site-packages\spacy\en\data to /tmp
Traceback (most recent call last):
File "C:\Users\garrett\Anaconda\envs\py3k\lib\runpy.py", line 160, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Users\garrett\Anaconda\envs\py3k\lib\runpy.py", line 73, in _run_code
exec(code, run_globals)
File ".\spacy\en\download.py", line 56, in <module>
plac.call(main)
File ".\plac_core.py", line 309, in call
cmd, result = parser_from(obj).consume(arglist)
File ".\plac_core.py", line 195, in consume
return cmd, self.func(*(args + varargs + extraopts), **kwargs)
File ".\spacy\en\download.py", line 51, in main
shutil.move(DEST_DIR, '/tmp')
File "C:\Users\garrett\Anaconda\envs\py3k\lib\shutil.py", line 521, in move
raise Error("Destination path '%s' already exists" % real_dst)
shutil.Error: Destination path '/tmp\data' already exists
appreciate any help or advice you can provide
You have hit this bug which should be already fixed in the last version. Apparently spacy can't download the data because the destination already exists (may be from a previous interrupted download). A workaround would be to delete the /temp/data folder and retry the download.

Resources