Cannot import installed python package (MacOS) - python-3.x

I cannot import any python package when running python on Visual Studio code or on my Terminal. I can still do this if I were to code on a Jupyter notebook. However, when I tried other environment that doesn't use the notebook server. It returns me ModuleNotFound Error like this
Traceback (most recent call last):
File "/Users/truongminh/Desktop/DataScience/Datasets/CityU Text/test_PreprocessText.py", line 1, in <module>
import PreprocessText
File "/Users/truongminh/Desktop/DataScience/Datasets/CityU Text/PreprocessText.py", line 1, in <module>
import pandas as pd
ModuleNotFoundError: No module named 'pandas'
Most of my packages was download via anaconda. I don't know if it might be the cause of this.

Related

ModuleNotFoundError: No module named 'six' - python 3.8.5

When trying to open jupyter notebook from my terminal in Visual Studio Code, I keep getting the error below. I have tried uninstalling and reinstalling six using conda install but the same issue persists. It was working fine yesterday so I don't know what happened between now and then. I'm using Python 3.8.5 in my virtual environment. Any ideas what could be the issue?
(dreams) C:\Users\jacks\Documents\dreams_project>jupyter notebook
Traceback (most recent call last):
File "C:\Users\jacks\Anaconda3\Scripts\jupyter-notebook-script.py", line 6, in <module>
from notebook.notebookapp import main
File "C:\Users\jacks\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 83, in <module>
from .services.kernels.kernelmanager import MappingKernelManager, AsyncMappingKernelManager
File "C:\Users\jacks\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 18, in <module>
from jupyter_client.session import Session
File "C:\Users\jacks\Anaconda3\lib\site-packages\jupyter_client\session.py", line 41, in <module>
from jupyter_client.jsonutil import extract_dates, squash_dates, date_default
File "C:\Users\jacks\Anaconda3\lib\site-packages\jupyter_client\jsonutil.py", line 10, in <module>
from dateutil.parser import parse as _dateutil_parse
File "C:\Users\jacks\Anaconda3\lib\site-packages\dateutil\parser\__init__.py", line 2, in <module>
from ._parser import parse, parser, parserinfo, ParserError
File "C:\Users\jacks\Anaconda3\lib\site-packages\dateutil\parser\_parser.py", line 42, in <module>
import six
ModuleNotFoundError: No module named 'six'
I had the same issue, six was showing as installed by conda and loading fine when imported manually in python. The base version of Jupyter Notebook would load, but Jupyter Notebook wouldn't load in my virtual environment.
Running pip3 install six from a terminal with my environment activated seemed to solve the issue but I don't know why!
Also make sure the path to Conda in the VS Python extension settings is correct.

ImportError while importing sklearn

I am using python 3.7
Recently I started getting this error while importing sklearn module.
I get the same error in Jupyter Notebook, Python IDLE, Pycharm virtual environment
>>> import sklearn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\aditya\AppData\Roaming\Python\Python37\site-packages\sklearn\__init__.py", line 75, in <module>
from .utils._show_versions import show_versions
File "C:\Users\aditya\AppData\Roaming\Python\Python37\site-packages\sklearn\utils\_show_versions.py", line 12, in <module>
from ._openmp_helpers import _openmp_parallelism_enabled
ImportError: DLL load failed: The specified module could not be found.
I have tried reinstalling too.
After that I copied contents of sklearn of venv of another project which had no issues. This thing worked for couple of times. But now it's not working again
Note: pandas, numpy, scipy etc are installed and working absolutely fine. Sklearn was also working fine few days back
This is an issue in the packaging in scikit-learn 0.22.0 which will be solved in 0.22.1 (released next week). The issue is tracked at: github.com/scikit-learn/scikit-learn/issues/15899. There are 2 possible workarounds:
Install scikit-learn from conda-forge (conda include the missing dll) by default: conda install conda-forge::scikit-learn
Install VC++ which will have the openmp library (https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads)

How to deal with "ModuleNotFoundError: No module named 'setup' "

I installed the module "pyunicorn" in Ubuntu 16.04 LTS and all the dependencies but when I import the module in python 3.7.3 i get this error :
>>> import pyunicorn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/anaconda3/lib/python3.7/site-packages/pyunicorn/__init__.py", line 43, in <module>
from setup import __version__
ModuleNotFoundError: No module named 'setup'
What should i do to make it run properly???
I had this problem. I wanted to install it on Google Colab. I tried installing pyunicorn directly from Github and it worked for me. Try using following instruction:
pip install git+https://github.com/pik-copan/pyunicorn.git#egg=pyunicorn

Unable to get to Jupiter Notebook and Jsonschema Missing

I have been solving issues with my MacBook Air for the past day and I have unfortunately again bumped into some more issues. You might have seen this question before, but I couldn't solve this issue after trying all answers from
Can't use Jupyter Notebook: jsonschema apparently missing
Basically, I am now trying to enter Jupyter Notebook. I (think I) have two of them, one Jupyter Notebook installed using pip3 (Python 3.6.0), and one from Anaconda, which I uninstalled. For Anaconda, although I used anaconda clean and the rm function according to their official website and several other Stack Overflow forums, I could not uninstall the BASH and so I just left it there and installed Jupyter Notebook using pip3. But when I type Jupyter Notebook in Terminal, there is an error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nbformat/validator.py", line 12, in <module>
from jsonschema import ValidationError
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/jsonschema/__init__.py", line 32, in <module>
from pkg_resources import get_distribution
ImportError: cannot import name 'get_distribution'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/jupyter-notebook", line 6, in <module>
from notebook.notebookapp import main
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/notebook/notebookapp.py", line 83, in <module>
from .services.contents.manager import ContentsManager
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/notebook/services/contents/manager.py", line 17, in <module>
from nbformat import sign, validate as validate_nb, ValidationError
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nbformat/__init__.py", line 33, in <module>
from .validator import validate, ValidationError
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/nbformat/validator.py", line 23, in <module>
raise ImportError(str(e) + verbose_msg)
ImportError: cannot import name 'get_distribution'
Jupyter notebook format depends on the jsonschema package:
https://pypi.python.org/pypi/jsonschema
Please install it first.
What I am using:
MacOS High Sierra 10.13.6
Macbook Air 2011 i7 4gb ram
Python 3.6.0 (pip3 to install Jupyter)
What I have installed in Python: Numpy, Pandas, Tensorflow, Keras
Thank you for helping! Please point out any errors or ways I can improve this question if possible. Also, try to answer solutions differently from Can't use Jupyter Notebook: jsonschema apparently missing .

import rpy2.ipython meet error ModuleNotFoundError: No module named 'IPython'

My python version is 3.6. my OS is windows. After install rpy2 module, when I type import rpy2, got no issue. But when type import rpy2.ipython, got error as below:
>>> import rpy2.ipython
Warning (from warnings module):
File "D:\Soft_app\Python\lib\site-packages\rpy2\ipython\rmagic.py", line 76
"either.")))
UserWarning: The Python package 'pandas' is strongly recommended when using `rpy2.ipython`. Unfortunately it could not be loaded, and we did not manage to load 'numpy' either.
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import rpy2.ipython
File "D:\Soft_app\Python\lib\site-packages\rpy2\ipython\__init__.py", line 1, in <module>
from .rmagic import load_ipython_extension
File "D:\Soft_app\Python\lib\site-packages\rpy2\ipython\rmagic.py", line 81, in <module>
from IPython.core.displaypub import publish_display_data
ModuleNotFoundError: No module named 'IPython'
Can help to figure out what's issue??
It seems that you are missing Ipython and pandas. Installing them should resolve your issue.
Run "pip install ipython" to install Ipython and run "pip install pandas" to install pandas.
Hopefully, this will solve your problem.
Happy Coding ~

Resources