resolved
I have set up a conda environment with anaconda, with python 3.9 and paho-mqtt 1.6.1. I have also tested an Environment that worked for someone else but it doesn't work on my System. Other packages work, like numpy.
The code fails at the first row
import paho.mqtt.client as mqtt wit the error ModuleNotFoundError: No module named 'paho.mqtt'; 'paho' is not a package.
Does anyone have a solution or at least some ideas i could try?
For example if i create a new conda env with conda env --create env python=3.9, and then try to run import numpy it obviously doenst run. Then i do pip install numpy and run it again and it works. Though if i do the same with import paho.mqtt it doesn't work even after pip install paho-mqtt.
This error:
ModuleNotFoundError: No module named 'paho.mqtt'; 'paho' is not a package
may also occur if you have named the main program file you created as paho.py and try to run it as python paho.py or another file has the name paho.py in the same folder from which you run your program. Python will consider your program file as a module and try to find something in it that is naturally not in it. About where Python is looking for modules, see sys.path (citate: "...if path[0] is the empty string, which directs Python to search modules in the current directory first...").
In this case, rename your program file so that its name does not equal with the name of the imported module.
Related
Hi i'm recently working on a module in python (package named pykiwoom)
I installed a module in conda 32-bit environment pip install pykiwoom and tried to import this
from pykiwoom.kiwoom import Kiwoom
This works perfectly fine when I execute this in python console in pycharm
However, when I try this in terminal error occurs
ModuleNotFoundError: No module named 'pykiwoom.kiwoom'; 'pykiwoom' is not a package
internal structure of package pykiwoom looks like this
pykiwoom
init.py
kiwoom.py
parser.py
Can somebody tell me why this error occurs?
I think where you install your package is important in your case. You can check the packages installed using pip list in terminal, and check if you find it there.
This solution provides overview of how to setup your files as packages and modules.
Nevertheless, I think if you install your package in the terminal using pip, you could possibly access it.
I'm trying to import pydriller using python interpreter in venv, after installing pydriller with pip I try the following:
from pydriller import RepositoryMining
but the IDE can't recognize "RepositoryMining" and I'm getting this error:
cannot import name 'RepositoryMining' from partially initialized module 'pydriller' (most likely due to a circular import)
Although I can see in the "venv" the "pydriller" folder which contains a file with the class "RepositoryMining",
And after that said, I tried to install pydriller on the system (without venv) and it worked, but the problem is that I need it to be working in the project with the virtual environment, any suggestions on how to fix it?
The problem was that my python file name was "pydriller.py", I needed to rename it to avoid import conflicts (hoping that this will help someone).
I have recently installed python 2.17.14 to use a package which I installed in the command prompt with:
python -m pip install packageName
However, whenever I try to use it with a script provided by the package authors, I get Import Errors:
ImportError: cannot import X from YX
ImportError: attempted relative import with no known parent package.
I don't know what I'm doing wrong, as I am really new to Python. Does anyone have any ideas?
The package is called neurodesign and I downloaded the try out script from the official website "neuropowertools.org"
Best,
Max
In case anyone (who is also new to python^^) fails ridiculously at this task as well: I had to manually install all the modules used within this package for it to work as they weren't installed automatically.
I have installed a custom module (Twilio) using PIP, but when I try to import it, it will bring up:
ImportError: No module named 'twilio'
I'm running Windows 10 and Python 3.5. What am I missing? It seems to be an error with the paths. If it is, how do I set the paths?
Edit: I have my PYTHONHOME set to C:\Python33 and my PYTHONPATH set to C:Python33\Lib
First of all you need to check your package location.
pip show custom_package
Then check the system paths by
import sys
sys.path
If you dont' see your package path here, you can add it.
sys.path.append(custom_package_path)
If this doesn't work try reinstalling it. Or you can also install it with easy_install
I'm trying to run tensorflow in a conda environment. I started off by creating a python 2.7 environment with conda create --name py27 python=2.7 and then activated it. Within the environment, I ran conda install -c https://conda.anaconda.org/jjhelmus tensorflow, which has tensorflow and numpy in the package, so hypothetically there shouldn't be any issues running numpy.
When I open up the python console within the environment, however, I'm continually getting ImportError: No module named multiarray and ImportError: cannot import name Random (I can import random with no issues, but then I get the multiarray issue) no matter how many times I uninstall/reinstall numpy/matplotlib (at one point I even uninstalled/reinstalled python) and no matter what versions of these I try to use, I keep on getting the same issue. What should I do?
There is an answer here.
Shortly: that issue has something with the version of numpy which is upgraded by another package by whatever reason. Try to specify version: conda create -n NAME numpy=1.9.3 other_package.
If that doesn't work, check if you have files in your working directory which names matches the names of some packages. For example, I had a similar problem after renaming numpy.py.txt (which is a sort of handmade cheatsheet) into just numpy.py and trying to import numpy within Python shell when I was in that directory.