Python "ImportError: cannot import name 'pnoise1' from 'noise'" - python

I have been trying to use the noise module in Python for a game I was making. I am on the Mac OS, and I used pip3 install noise to download the module. I uninstalled and reinstalled it multiple times, without the wheel library, and with, as it recommended. The noise module itself downloads fine, but every time I try to import pnoise from it, I get an ImportError.
Just straight up importing noise (import noise) gives me no error, it just prints a string of numbers to my console. Also, downloading and running the module in a virtual environment works, so it must be something on my computer or OS.
Code: from noise import pnoise1
Error: ImportError: cannot import name 'pnoise1' from 'noise'
I have looked for a while for a solution, but nothing has seemed to help, it just doesn't work. The only information I have found is that this may be a file problem, but I haven't found out how to fix it.
Any help would be greatly appreciated.
Edit:
I ended up figuring it out. I was importing a file by the same name instead of the library. Thanks for the help, everyone!

To me it works ok. Have you installed it correctly via pip/pip3?

Ended up figuring it out, I was importing a file of mine instead of the library. Thanks for the help!

Related

ImportError: cannot import name 'Random' from 'django.db.models.functions'

Well, I am trying to run my django project in new environment, I installed all of my requirements although every package is installed but it is still giving me below mentioned error. I am not sure but I am guessing it is due to version conflict of some modules.
I looked for existing solutions or someone who faced similar situation but no success.
the Random method is located in django/db/models/functions/math.py . change your import statement to this :
from django.db.models.functions.math import Random

ImportError: cannot import name 'WatermarkEncoder' from 'imWatermark'

I'm trying to run stable diffusion on my local pc. It's a macbook pro m1. Even though I did follow every single step, I keep getting an import error. What might possibly be the reason and how may I fix it?
ImportError: cannot import name 'WatermarkEncoder' from 'imWatermark'
I was referring an online tutorial so I did end up searching through the comments. Found nothing so far.
If you look in the txt2img.py script it references https://github.com/ShieldMnt/invisible-watermark
Install with pip install invisible-watermark
It seems they forgot to add it into requirements.txt or smt like that.
If you continue getting the error after invisible-watermark installation, change the line from imWatermark import WatermarkEncoder in txt2img.py to from imwatermark import WatermarkEncoder (lowercase)

Problem with running python code on VS Code

[enter image description here][1]
Hello there,
I am facing the problem you can see in the image.
[1]: https://i.stack.imgur.com/qjV9Z.png
I have python installed in the D directory and added to path, everything looks like it should work.
I am creating a virtual environment for every project I am working on and I don't have any problems running commands like "pip install numpy" but when I try to run my code, even trying to import libraries it fails and the output in the picture is not very significant to me.
Has anyone faced a similar problem? can anyone help me?
Thanks in advance!
Judging from your screenshot, you have a file named numpy.py somewhere in your PYTHONPATH, causing Python to import that particular file instead of the NumPy library you intended.
See this link for more information on how Python import works: https://bic-berkeley.github.io/psych-214-fall-2016/sys_path.html

Anacaonda/Windows 10 - ModuleNotFoundError: No module named 'scipy'

I recently updated Anaconda (Spyder (Python 3.6), Windows 10). Several of my libaries disappeared and had to be re-installed. However, I have been unable to reinstall scipy. When I run "conda install scipy -f" from the Windows PowerShell, scipy seems to be reinstalled. However even if I close Spyder and restat Windows, I continue to get the error: ModuleNotFoundError: No module named 'scipy'.
I know that problems similar to this one have been posted previously, but I have been unable to find anything that seems to fix the problems.
Thanks in advance for any advice (and apologies if this question was posted yesterday as well).
I battled with this same issue. The reason is most likely because you already have a file in the current directory called scipy.py. For example, when I first started with scipy, i made a file literally called scipy.py to practice in. Then, when I tried to import scipy from a different file, the first instance of 'scipy.py' was my practice folder, rather than the actual package which was further into the directory.
I advise you check for folders that you may have named scipy.py that aren't the actual scipy package. I could be wrong, but it seems likely that python will first search the folder it saves your files to, and then trundle over to the packages folder saved elsewhere.
Hopefully this helps some other folks who are stumped by the same issue!

"No Module Named" error in Jupyter

A very similar problem, but different solution.
When I try to do import speech_recognition as sr in Jupyter, it returns the no moduled named... error.
But doing it in a terminal is fine. So I looked through the sys.paths of both. In Jupyter:
//anaconda/lib/python3.5/site-packages/six-1.10.0-py3.5.egg',
'/Users/don',
'/Users/don/Users/don/Documents/PyModules/skynet',
'//anaconda/lib/python35.zip',
'//anaconda/lib/python3.5',
'//anaconda/lib/python3.5/plat-darwin',
'//anaconda/lib/python3.5/lib-dynload',
'/anaconda/lib/python3.5/site-packages/Sphinx-1.3.1-py3.5.egg',
'//anaconda/lib/python3.5/site-packages',
'//anaconda/lib/python3.5/site-packages/aeosa',
'//anaconda/lib/python3.5/site-packages/IPython/extensions',
'/Users/don/.ipython'
In terminal:
/Users/don/Applications/miniconda3/lib/python3.5/site-packages
/datashader-0.4.0-py3.5.egg
/Users/don
/Users/don/Users/don/Documents/PyModules/skynet
/Users/don/Applications/miniconda3/lib/python35.zip
/Users/don/Applications/miniconda3/lib/python3.5
/Users/don/Applications/miniconda3/lib/python3.5/plat-darwin
/Users/don/Applications/miniconda3/lib/python3.5/lib-dynload
/Users/don/Applications/miniconda3/lib/python3.5/site-packages
/Users/don/Applications/miniconda3/lib/python3.5/site-packages/setuptools-23.0.0-py3.5.egg
If I run this first in Jupyter, then the module speech_recognition imports fine:
sys.path.append('/Users/don/Applications/miniconda3/lib/python3.5/site-packages')
I'd just like to know what's going on? I've found a solution of sorts, but I'd like a more elegant one, so I don't have to do sys.path.append every time. This is particularly endemic to a bunch of modules I've installed lately using pip install <module>.
This fixed it, but I don't know how or why. I just did $ pip3 install jupyter, and everything magically imported correctly after that. Nevertheless, if someone could give me a clue about what got fixed (because I don't even know what went wrong), that would be great.

Categories

Resources