ModuleNotFoundError: No module named 'ipytest.magics' - python

I am new to Jupyter notebook, and while trying to run the following code:
import sys
!{sys.executable} -m pip install pytest
!{sys.executable} -m pip install ipytest
import ipytest.magics
import pytest
I ran into the ModuleError. None of the code above that caused any problems. What is the reason for this, and what can I do to solve it?
(My Python version is 3.7.4)

I met the same problem. I checked the latest document of ipytestipytest document 0.9.1, it changed the sytle of writing, so i also changed. You can try
import ipytest
import pytest
ipytest.autoconfig()

Related

ModuleNotFoundError: No module named 'pycoin'

Code:
from pycoin.ecdsa.secp256k1 import secp256k1_generator
When I run this, I get the error:
ModuleNotFoundError: No module named 'pycoin'
I've tried doing:
pip3 install pycoin
aswell as
pip install pycoin
Both of which have lead to the same error.
I've ran the code on python and python3 which also leads to the same error.
Any solutions?
Go to terminal or cmd on windows and type python3 (python2, python for older versions)
Then try to import the module there.
If the module in imported successfully then reopen your IDE. and then try.

Why do I get 'No module named 'currency-symbols' when importing xls2xlsx, even though 'pip install currency-symbols' returns requirement satisfied?

My IDE is Spyder and the distribution I am using is miniconda. I use pip install in the anaconda prompt window (as I usually do).
'pip install xls2xlsx' seems to run fine and install the package.
When I try 'from xls2xlsx import XLS2XLSX' I get the following error:
ModuleNotFoundError: No module named 'currency-symbols'
If I try 'pip install currency-symbols' , I get:
'Requirement already satisfied: currency-symbols in c:\users\user\miniconda3\lib\site-packages (2.0.2) '
I can see both directories in the site-packages directory.
So I had the same or very similar problem, my trace-back said it could not import currency_symbols. I found that the module it was trying to import was the constants from that package. So I went into the py file where xls2xlsx had the issue
"htmlxls2xlsx.py" my traceback said line 40..
currency_symbols_constants =
importlib.import_module('currency-symbols.constants')
I noticed this was part of an 'exception' so I fixed line 37 from import currency_symbols.constants as currency_symbols_constants to import currency_symbols._constants as currency_symbols_constants
Now it imports just fine.
I also had version 2.0.2 of currency-symbols installed, but my working host was using 2.0.1. I discovered that if you install 2.0.1, the issue did not occur.
pip3 install -Iv currency-symbols==2.0.1

azure functions module errors using python

I'm new to azure so excuse my lack of knowledge about the platform. I'm currently trying to run and deploy an azure function using python. these modules are currently found in my requirements.txt file
azure-functions
graphqlclient
requests
gql
asyncio
aiohttp
I run the following command pip install -r requirements.txt to install them, but for some reason, some modules cannot be found. for example the json module. import json works fine with any other python program. but when i try and add it to the requirements.txt file and run this command pip install -r requirements.txt i get the following error
ERROR: Could not find a version that satisfies the requirement json (from versions: none)
ERROR: No matching distribution found for json
i tried adding a version, but that did not solve my issue. thats only half my problem, i decided to ignore this problem for now and try to work with the modules that are working properly in the .txt file. moving on to my __init__.py file which is a timer trigger i have the following imports
import datetime
import logging
from graphqlclient import GraphQLClient
import requests
import asyncio
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport
import azure.functions as func
but when i try and run my function i get the following error
Exception: ModuleNotFoundError: No module named 'gql.transport.aiohttp'
Can someone please explain these module erros? all these modules work fine when i run them from any other python program, so the problem seems to be from azure.
Thanks
I run the following command pip install -r requirements.txt to install them, but for some reason, some modules cannot be found. for example the json module.
Json is a standard library in python there's no need to install it.
Just include it in your python script as the following:
import json
Exception: ModuleNotFoundError: No module named 'gql.transport.aiohttp'
According to my test results, the default version of gql installed using the pip install -r requirements.txt command is 2.0.0.
If you use from gql.transport.aiohttp import AIOHTTPTransport to import AIOHTTPTransport, you need to install 3.x.x.
So this error is caused by version incompatibility.
Solution:
Please install the 3.x.x version of gql, you can uninstall the installed gql first, and then reinstall the new version of gql:
pip uninstall gql
pip install gql==3.0.0a5
I did some tests and the function can run normally.

Multiple errors importing and using mglearn

I'm getting multiple errors trying to install and import the mglearn library into a Jupyter notebook. I've installed mglearn using the command line using pip install mglearn and also directly into Jupyter using !pip install mglearn. However, when I try to import mglearn I get the error ModuleNotFoundError: No module named 'mglearn'. If I try to install it again I get a Requirement already satisfied response.
I then went into the python terminal with $python3 and tried import mglearn, which was successful. I checked the version and I get 0.1.7.
I've also tried the following code within Jupyter:
import sys
!{sys.executable} -m pip install mglearn
With that code I get a zsh:1: no matches found: error.
I know it's installed and I'm importing it. I'm out of ideas for how to fix this. Any help would be appreciated.

ModuleNotFoundError: No module named 'numpy' - Jupyter Notebook

I'm facing weird issue in my Jupyter-notebook.
In my first cell:
import sys
!{sys.executable} -m pip install numpy
!{sys.executable} -m pip install Pillow
In the second cell:
import numpy as np
from PIL import Image
But it says : ModuleNotFoundError: No module named 'numpy'
I have used this command to install Jupyter notebook :
sudo apt install python3-notebook jupyter jupyter-core python-ipykernel
Additional information :
pip --version
pip 20.2.2 from /home/maifee/.local/lib/python3.7/site-packages/pip (python 3.7)
python --version
Python 3.7.5
Thanks to #suuuehgi.
When Jupyter Notebook isn't opened as root:
import sys
!{sys.executable} -m pip install --user numpy
I've had occasional weird install issues with Jupyter Notebooks as well when I'm running a particular virtual environment. Generally, installing with pip directly in the notebook in this form:
!pip install numpy
fixes it. Let me know how it goes.
Restarting the kernal from the Jupyter Notebook solved this issue for me
I had a similar issue. Turns out I renamed an upstream path. And I hadn't deactivated my conda env first. When I deactivated the env.
conda deactivate
Then when I activated it again, everything was as it should have been.
conda activate sample
Now I am seeing other issues with jupyter themes... but its not impacting my numpy code. So, at least I fixed the "ModuleNotFoundError: No module named 'numpy'" error
I have the same problem. My numpy is installed, I am using the same folder as usual.
If I try 'conda deactivate', I get the message:
ValueError: The python kernel does not appear to be a conda environment. Please use %pip install instead.
I added a print of the 'pip install numpy' result and the 'Module not found error' after
Here is a solution which worked for me:
lib_path="c:\\users\\user\\python_39\\lib\\site-packages\\"
MODULE_NAME = "module_to_import"
MODULE_PATH = lib_path+MODULE_NAME+"\\__init__.py"
import importlib
import sys
spec = importlib.util.spec_from_file_location(MODULE_NAME, MODULE_PATH)
module = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = module
spec.loader.exec_module(module)
import module_to_import

Categories

Resources