I have been trying to run the Mask R-CNN demo from matter plot (https://github.com/matterport/Mask_RCNN). It works with tensorflow version 1.13.1 and keras 2.1.0 as suggested by someone here (https://github.com/matterport/Mask_RCNN/issues/1797). I get the error
ModuleNotFoundError: No module named 'astor'
The thing is astor 0.8.0 is installed in my virtual env but when trying to import it, it say it does not exist. I have made sure to install it normally as well as sudo. If you think it does exist on $PYTHONPATH, how can I do it. I am out of my depth here, so please be considerate.
EDIT: I am using virtualenv in pyCharm. If I look through my interpreter paths, I get
file:///home/$SUER/anaconda3/lib/python3.6
file:///home/$USER/anaconda3/lib/python3.6/lib-dynload
file:///home/$USER/project/Mask_RCNN/venv/lib/python3.6/site-packages
file:///home/$USER/anaconda3/lib/python3.6/site-packages
I have replace my actual user name with $USER in the above output.
Thanks to #bigbounty, but his questions made me understand a bit more about PYTHONPATH. Maybe something that I already should have known but you make mistakes and learn.
SOLUTION: in the venv interpreter paths I added
/home/$USER/anaconda3/pkgs/astor-0.8.0-py36_0/lib/python3.6/site-packages
and it worked. I do not know why the package was installed in this folder where apparently it was not included.
i solve copyng the astor folder from site-package (in env) to my project folder and set is as source( in pycharm)
Related
I am building a desktop app using Python and PySimpleGUI. So far, everything works just fine. Whilst I was working at the project, I realized I need to find a way to get the duration of some mp3 files and to display it in a certain way. I discovered mutagen module that is supposed to help me in this sense, I installed, and here the problem arise:
It throws me ModuleNotFoundError: No module named 'mutagen'.
Seeing this, I started to look for the problem, but I couldn't not understand why my interpretor did not find the module even though I Installed it CORRECTLY. (as PyCharm told me)
I have tried the following:
I am using a local virtual environment that has installed the dependecies for the project(and some extra) and I uninstalled and installed the package 3-4 times
I deleted the local virtual environment and I created another one. I installed the packages again and same issue.
I installed a random module (scipy) and I tried to import it somewhere in the project and it thrown me same error, but this time for scipy module
My guess is that I did not configured properly my interpreter, but to be honest, I have no idea what I am doing wrong, because I followed the same steps I've been using for creating a venv with its according interpreter and for other projects, it worked just fine.
Further details:
Using python3.9 base .exe
I installed the packages in two ways: one using the pycharm IDE, and one by running pip3 install mutagen
You may be using a different pip that is not the one that affects the Python you are using. Instead of using
pip install mutagen
Consider using pip as a module of the Python you are using:
python -m pip install mutagen
This way you'll be sure you are working on the same Python.
If you want to continue using plain pip, try which python and which pip to make sure they are referencing the same environment.
I am having the error while running jupyter notebook. Error replication:
python --version
Python 3.7.9
python
import win32api
The error was: ImportError: DLL load failed
After doing a some stackoverflow, I got to know that there are 2 dll files missing namely: pythoncom37.dll and pywintypes37.dll
I also got to know that I can run this post command: pywin32_postinstall.py in the Scripts folder. I ran this script. Restarted my pc. I manually download these two dll and copied it to my system32. After manually downloading, I started to have a different type of error: ImportError: DLL load failed: %1 is not a valid Win32 application
I used anaconda and ran my jupyter notebook which was my main aim but can you please make me aware as what is going wrong?
I've run into this recently, but with a different version of the DLLs. What solved it for me was using a different version of pywin32.
My solution (conda env, python 3.8.5):
pip install pywin32==300
or try 225, 227, 228. The latest pywin32 (301 as of this post) seems to be having dll search issues (I wouldn't be surprised if whatever version you were using is also having dll search issues). 301 was released after your issue started, but you may have a similar problem nonetheless.
There is currently an issue on pywin32 DLL loading failing: https://github.com/mhammond/pywin32/issues/1709
Factors involved (in my experience) include your PATH variable (if you're using conda). I haven't tested it myself, but I'd be curious to see if this issue occurs without conda. This issue stops happening for me if the first dlls found are those for 301. In my case, that means putting them in my C:\Windows\System32 folder (yeah I'm on Windows; joy).
So a possible solution #2 would be to run the pywin32 post install script which should be located under your venv/Scripts/pywin32_postinstall.py
To try that solution, open an ADMIN command prompt (very important that it's admin), navigate to your venv, and run:
ppython.exe Scripts\pywin32_postinstall.py --install
You shouldn't HAVE to do this, but if you just need a one-off solution and it works, great!
pip install --upgrade pywin32 ==225 worked for me. Tried version 300 and was unsuccessful.
I know this question has been asked thousands of times, but I still don't get the correct answer and stumble upon the same problem always.
I have the following file:
application/app/__init__.py
Here, I have some variable, let it be x.
Then, I have another file here:
application/tests/test_1.py
In test_1.py I do this:
from app import x
And, being in the application folder, I run:
python3 tests/test_1.py
But the following error happens:
ModuleNotFoundError: No module named 'app'
One solution that works is, inside test_1.py, add:
import sys
sys.path.append('../')
from app import db
Then if I do:
cd tests
python3 test_1.py
It works perfectly, but I don't want that sys.path.append and also I would like to do
python3 tests/test_1.py
Another solution is to explicitly modify the PYTHONPATH environment variable, but again, I wouldn't like to do this. Isn't there a clean solution to this problem?
Do not manually "hack" the sys.path. This is a bad practice "quick fix" that you've probably learned from stackoverflow answers.
Python looks for imports in either the site-packages folder or in the PYTHONPATH. The easiest way to get your local folder into the site-packages is using
pip install --editable path/to/myfolder
You only need a setup.py in your program "myfolder" with the following contents
from setuptools import setup
setup(name='myfolder")
The name "myfolder" is only important in case you want to uninstall it. But eventually this will create a symlink of your myfolder in the environments site-packages, and you can continue editing as before. But your program works "as if installed".
This is way more flexible than changing the PYTHONPATH.
As for the other comment:
When `application' is linked to site-packages and thereby recognized via sys.path,
from app import x
is an absolute import, since 'app' is a folder inside the top level folder 'application'.
I've been having a problem with installing packages in PyCharm. This started happening a few months ago, but before that it was fine. I can install it from the cmd using pip, but when I try to import it into the IDE it gives this error:
ModuleNotFoundError: No module named '_winreg'
and isn't available for use. The package I'm trying to install right now is pygame, but it has had trouble with other ones. I tried to make sure I have winreg installed by using 'pip3 install winreg' in the cmd, but it gives error text saying, "Could not find a version that satisfies the requirement winreg." What am I doing wrong?
Also, if it helps, I'm using Windows and the latest version of PyCharm, as well as python 3. Thanks for the help, I've been looking for a while now.
I think one of your problems possibly is that you didn't add pygame in your project interpreter. (To add it go to File -> Settings -> Project Interpreter then click the green plus sign and search for pygame.) I don't know if this will work for winreg, but tell me if it does.
I can't find _winreg anywhere, I've searched winreg's file, and modules , there don't seems like any of _winreg. I think you probably want to import winreg, not _winreg.
And also, if you are using PyCharm's venv, you need to use the project's prompt to import,or project interpreter.
Could not find a version that satisfies the requirement sometime means your python's version is too new for the module to use.
I'm using Windows 7 and am up to date on patches. I was using Python 3.5.2 and wanted to upgrade to 3.6, so I went to the Python site, downloaded 3.6.4.exe for Windows, and ran it. The Python seems to work fine and is 3.6.4, but trying to import any of the packages I was using (pandas, numpy, tensorflow, etc) now gives me ModuleNotFoundError: No module named <whichever module it was>. Also, pip list now shows only pip and setuptools.
It appears to be a known issue, for example this from nearly a year ago, which suggests that I should "uninstall the python bindings and install again", but I can't figure out what that means. Fortunately I can still access 3.5.2 by using py -3.5, and then my imports work. Can anyone tell me how to fix this for 3.6 without having to reinstall all my modules manually?
I was thinking possibly I should have upgraded through pip; it seems like that's possible but maybe a bad idea for some reason? On further investigation it looks like what I should have done was save my requirements with pip freeze > requirements.txt, and then after installing the new Python restore them with pip install -r requirements.txt. Is this right?
Hard to say if you have an install problem, but this is what I would try if I were in your place.
Create a virtual environment as per; docs
c:>c:\Python36\python -m venv c:\path\to\myenv
Activate your virtual environment
C:> \Scripts\activate.bat
Run your application from within your activated environment. Each time you get an import error, do a pip-install from within the active environment. (For your own modules, you may need to modify PYTHONPATH in 'activate.bat')
Once you have your application running again, do your pip freeze > requirements.txt, and keep that with your project.
Each time you run your application, do so from within the activated virtual environment.
This will give you a clean requirements.txt that doesn't include a bunch of junk from other projects. Then, when you go to 3.7, just create the virtualenv and run your requirements.txt and wala!
I suspect your issue is simply not running against the correct interpreter, running from within a virtual environment should at least rule it out.