IPython console unavailable on spyder - ipython

I recently tried to switch from IPython console to python console in spyder and can't get back IPython console.
I tried to uninstall and install spyder and ipython but it didn't change anything. Typing:
import IPython
IPython.start_ipython()
didn't change anything either. I had this mistake:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/IPython/__init__.py", line 45, in <module>
from .config.loader import Config
File "/usr/lib/python2.7/dist-packages/IPython/config/__init__.py", line 16, in <module>
from .application import *
File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 32, in <module>
from IPython.config.configurable import SingletonConfigurable
File "/usr/lib/python2.7/dist-packages/IPython/config/configurable.py", line 34, in <module>
from IPython.utils.text import indent, wrap_paragraphs
File "/usr/lib/python2.7/dist-packages/IPython/utils/text.py", line 28, in <module>
from IPython.external.path import path
ImportError: cannot import name path
I checked the status of my spyder depencies and it does not detect IPython correctly:
IPython >=1.0 : None (NOK)
jedi >=0.8.1;<0.9.0: 0.9.0 (NOK)
matplotlib >=1.0 : 1.5.1 (OK)
pandas >=0.13.1 : 0.17.1 (OK)
pep8 >=0.6 : None (NOK)
psutil >=0.3 : 3.4.2 (OK)
pyflakes >=0.5.0 : 1.1.0 (OK)
pygments >=1.6 : 2.1 (OK)
pylint >=0.25 : 1.5.2 (OK)
rope >=0.9.2 : 0.10.2 (OK)
sphinx >=0.6.6 : 1.3.6 (OK)
zmq >=2.1.11 : 15.2.0 (OK)
How can I fix it ?
Thank you som much !

Related

pyspark launch issue ubuntu 16.04

I just now installed apache-spark 3.1.2 on ubuntu 16.04. After installation and setting up PATH, SPARK_HOME, PYSPARK_PYTHON environment variables, when I try to launch pyspark I am getting below error:
$ $SPARK_HOME/bin/pyspark
Python 3.5.2 (default, Jan 26 2021, 13:30:48)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
File "/opt/spark/python/pyspark/shell.py", line 29, in <module>
from pyspark.context import SparkContext
File "/opt/spark/python/pyspark/__init__.py", line 53, in <module>
from pyspark.rdd import RDD, RDDBarrier
File "/opt/spark/python/pyspark/rdd.py", line 48, in <module>
from pyspark.traceback_utils import SCCallSiteSync
File "/opt/spark/python/pyspark/traceback_utils.py", line 23, in <module>
CallSite = namedtuple("CallSite", "function file linenum")
File "/opt/spark/python/pyspark/serializers.py", line 390, in namedtuple
for k, v in _old_namedtuple_kwdefaults.items():
AttributeError: 'NoneType' object has no attribute 'items'
Error in sys.excepthook:
I get same error when I try to import pyspark from python3
$ python3
Python 3.5.2 (default, Jan 26 2021, 13:30:48)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyspark
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/pyspark/__init__.py", line 53, in <module>
from pyspark.rdd import RDD, RDDBarrier
File "/usr/local/lib/python3.5/dist-packages/pyspark/rdd.py", line 48, in <module>
from pyspark.traceback_utils import SCCallSiteSync
File "/usr/local/lib/python3.5/dist-packages/pyspark/traceback_utils.py", line 23, in <module>
CallSite = namedtuple("CallSite", "function file linenum")
File "/usr/local/lib/python3.5/dist-packages/pyspark/serializers.py", line 390, in namedtuple
for k, v in _old_namedtuple_kwdefaults.items():
AttributeError: 'NoneType' object has no attribute 'items'
Error in sys.excepthook:
I am clearly missing some dependency/configuration but unable to figure out which one?
I did notice that pyspark command references
/opt/spark/python/pyspark/
while python3 references
/usr/local/lib/python3.5/dist-packages/pyspark
Spark home is /opt/spark. spark-shell is working perfectly fine by the way. So it appears that the issue is with python.
Update: I installed spark 3.0.3 and the issue isn't happening. Looks like this is something specific to 3.1.2
According to the documentation, Python 3.5.2 is not supported by Spark 3.1.2. Simply update Python to version 3.6 or above.

Can't import scipy

My issue is about the import of scipy
Reproducing code example:
import scipy
Error message:
Traceback (most recent call last):
File "D:/Projects/gait/tests/__init__.py", line 2, in <module>
import scipy
File "C:\Users\Leynier\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\__init__.py", line 110, in <module>
from scipy._lib._version import NumpyVersion as _NumpyVersion
File "C:\Users\Leynier\AppData\Local\Programs\Python\Python37-32\lib\site-packages\scipy\_lib\__init__.py", line 14, in <module>
from scipy._lib._testutils import PytestTester
ValueError: source code string cannot contain null bytes
Process finished with exit code 1
Scipy/Numpy/Python version information:
Scipy version: 1.3.0
Numpy version: 1.16.4
Python version: 3.7.3
OS: Windows 10

Jupyter Notebook from command line - ImportError - cannot import name 'TYPE'

Traceback (most recent call last):
File "/Users/codymitchell/Documents/code/py/zipline/venv/bin/jupyter-notebook", line 6, in <module>
from notebook.notebookapp import main
File "/Users/codymitchell/Documents/code/py/zipline/venv/lib/python3.5/site-packages/notebook/__init__.py", line 25, in <module>
from .nbextensions import install_nbextension
File "/Users/codymitchell/Documents/code/py/zipline/venv/lib/python3.5/site-packages/notebook/nbextensions.py", line 610, in <module>
from .extensions import (
File "/Users/codymitchell/Documents/code/py/zipline/venv/lib/python3.5/site-packages/notebook/extensions.py", line 8, in <module>
from tornado.log import LogFormatter
File "/Users/codymitchell/Documents/code/py/zipline/venv/lib/python3.5/site-packages/tornado/log.py", line 34, in <module>
from tornado.escape import _unicode
File "/Users/codymitchell/Documents/code/py/zipline/venv/lib/python3.5/site-packages/tornado/escape.py", line 27, in <module>
from tornado.util import unicode_type
File "/Users/codymitchell/Documents/code/py/zipline/venv/lib/python3.5/site-packages/tornado/util.py", line 21, in <module>
from typing import (
ImportError: cannot import name 'Type'
I had the same issue, here's how I solved it
Python 3.5.1 doesn't have typing.Type
https://github.com/django-extensions/django-extensions/issues/1188
C:\Users\rigupta>D:\Anaconda3\python
Python 3.5.1 |Anaconda 4.0.0 (64-bit)| (default, Feb 16 2016, 09:49:46) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import typing
>>> typing.Type
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'typing' has no attribute 'Type'
>>> typing.type
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'typing' has no attribute 'type'
>>>
so I upgraded my python version to 3.5.4 by running below command which resolved the issue
conda update --all
https://www.youtube.com/watch?v=Q-dZCAk1tfc
I had the exact same problem. I am running windows 7 64-bit, running on Portable Python 3.7.3.
When Jupyter was failing, I was running Portable Python at this path:
E:\applications\python37\Portable Python-3.7.3\App\Python
Uninstalling and reinstalling Jupyter, typing modules did not solve the problem.
I was suspicions of problematic path-names, so I copied the python installation to a path without whitespaces (and maybe a shorter path?):
E:\applications\python37\Python
Finally, I managed to get Jupyter Notebook to work!

How to use the ibm_boto3 in python

Who has the same problem?
I want to store data in cos, but cannot use the ibm_boto3 on my machine.
To be sure to check with a sample, I used the code from the sample from this ibm-cos-sdk github.
Installed
pip3 freeze
backports.functools-lru-cache==1.5
botocore==1.12.28
docutils==0.14
futures==3.1.1
ibm-cos-sdk==2.3.2
ibm-cos-sdk-core==2.3.2
ibm-cos-sdk-s3transfer==2.3.2
-e git://github.com/boto/jmespath.git#1c9c35cf681b6605d8629e5ce8865221a4fd2a30#egg=jmespath
mock==1.3.0
nose==1.3.3
pbr==5.0.0
python-dateutil==2.7.3
s3transfer==0.1.13
six==1.11.0
urllib3==1.23
Here is my cli result and as you can see the ibm_boto3 is not found.
python3 test.py
Traceback (most recent call last):
File "test.py", line 1, in <module>
import ibm_boto3
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ibm_boto3/__init__.py", line 16, in <module>
from ibm_boto3.session import Session
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ibm_boto3/session.py", line 27, in <module>
import ibm_botocore.session
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ibm_botocore/session.py", line 37, in <module>
import ibm_botocore.credentials
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ibm_botocore/credentials.py", line 36, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
Yeah, it looks like requests somehow fell out of the requirements file in the latest release. The team is patching it and will release an update soon.
In the meantime, you can manually install the package in your environment with pip3 install requests or by manually adding it to the requirements.txt file:
echo "requests==2.18.0" >> path/to/requirements.txt

Import Error of IBM Watson Natural Language Understanding API

I am now trying to extract keywords by using IBM Watson Natural Language Understanding API. I follow the instruction and have installed the watson_developer_cloud. However, I met an error when import the NaturalLanguageUnderstandingV1. Could you help me with it? Thank you!
from watson_developer_cloud import NaturalLanguageUnderstandingV1
Traceback (most recent call last):
File "<ipython-input-11-ab5aa6f014f4>", line 1, in <module>
from watson_developer_cloud import NaturalLanguageUnderstandingV1
File "C:\Users\yipin\Anaconda3\envs\tensorflow\lib\site-
packages\watson_developer_cloud\__init__.py", line 30, in <module>
rom .speech_to_text_v1 import SpeechToTextV1
File "C:\Users\yipin\Anaconda3\envs\tensorflow\lib\site-
packages\watson_developer_cloud\speech_to_text_v1.py", line 74, in <module>
from watson_developer_cloud.websocket import RecognizeCallback, RecognizeListener
File "C:\Users\yipin\Anaconda3\envs\tensorflow\lib\site-packages\watson_developer_cloud\websocket\__init__.py", line 18, in <module>
from .speech_to_text_websocket_listener import RecognizeListener
File "C:\Users\yipin\Anaconda3\envs\tensorflow\lib\site-packages\watson_developer_cloud\websocket\speech_to_text_websocket_listener.py", line 21, in <module>
from twisted.internet import ssl, reactor
File "C:\Users\yipin\Anaconda3\envs\tensorflow\lib\site-packages\twisted\internet\ssl.py", line 59, in <module>
from OpenSSL import SSL
File "C:\Users\yipin\Anaconda3\envs\tensorflow\lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "C:\Users\yipin\Anaconda3\envs\tensorflow\lib\site-packages\OpenSSL\crypto.py", line 16, in <module>
from OpenSSL._util import (
File "C:\Users\yipin\Anaconda3\envs\tensorflow\lib\site-packages\OpenSSL\_util.py", line 6, in <module>
from cryptography.hazmat.bindings.openssl.binding import Binding
File "C:\Users\yipin\Anaconda3\envs\tensorflow\lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 13, in <module>
from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: DLL load failed: The operating system cannot run %1.
After reinstalling the watson-cloud-developer as an administrator. I solve the problem. It seems that if we do not run the pip install command as an administrator, then the package cannot be installed correctly.