This is a FRESH installation of Anaconda, so the issues with updating python don't apply here. Uninstalling and reinstalling causes the same errors.
Upon starting up the Anaconda prompt I get this error:
Traceback (most recent call last):
File "D:\AnacondaInstallation\Scripts\conda-script.py", line 11, in <module>
from conda.cli import main
ModuleNotFoundError: No module named 'conda'
C:\Users\xianx>where conda
INFO: Could not find files for the given pattern(s).
I manually added these three lines to my Path variable, but I'm still getting that error upon opening up the Anaconda prompt.
D:\AnacondaInstallation\Scripts,
D:\AnacondaInstallation,
D:\AnacondaInstallation\Library\bin
I also see it when I try to install any sort of package. The system seems to recognize the conda command enough to run conda-script.py.
D:\AnacondaInstallation\Scripts>conda install pytorch
Traceback (most recent call last):
File "D:\AnacondaInstallation\Scripts\conda-script.py", line 11, in <module>
from conda.cli import main
ModuleNotFoundError: No module named 'conda'
D:\AnacondaInstallation\Scripts>where conda
D:\AnacondaInstallation\Scripts\conda.exe
D:\AnacondaInstallation\Library\bin\conda.bat
My problem was that I had multiple Python installations all over the place. Once I cleaned those out of my PATH environment variable and put in the Anaconda ones, the issue resolved itself.
Related
I am trying to import a python module from a certain folder. This is the code:
import sys
sys.path.append(r"C:\path\to\module_foobar")
import foobar
In a miniconda env with all prerequisites installed (python 3.10 and numpy), I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed while importing foobar: The specified procedure could not be found.
But with the system python in cmd, the same code works.
Tried adding the path to system path variable as well as specifying it in a custom .pth file in the site-packages folder of the miniconda environment.
Tried running dependencywalker on the .pyd file of the package and it says that a bunch of MS C++ Redistributeable dll files seem to be missing. Tried repairing those to no avail.
What on earth could be wrong?
When I first ran the server everything was fine and the project was running properly. But after few days when I ran the server again, it gave me an error
Traceback (most recent call last):
File "C:\Users\Admin\Desktop\Django Project\first\manage.py", line 11, in main
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Admin\Desktop\Django Project\first\manage.py", line 22, in <module>
main()
File "C:\Users\Admin\Desktop\Django Project\first\manage.py", line 13, in main
raise ImportError(
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
To be specific, I'm on Windows 10, using VS Code as my IDE (I've not setup any virtual environment).
Django version installed - 3.2.9
Python version installed - 3.10.0
PIP version installed - 21.2.3
Here is a screenshot of my Environment Variables
[
I don't know what the problem was. Thanks to everyone for their suggestions. I deleted the project and created a new one and it worked. I hope I won't face any such issue while working on a big project!
When I try to use installed packages in Python, I nearly always run into the same error.
So I e.g. install a package like this: pip3 install mathplot and when I afterwards want to use it in Python3 (I use python3 in the command prompt), I run into the ModuleNotFoundError:
>>> import mathplot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mathplot'
But when I run just python, the module is found and ready to use.
Any idea where this problem comes from and how I can get rid of it?
Thanks in advance
When I use Anaconda, importing numpy gives me the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File"C:\Users\s140041\Anaconda3\envs\testenv\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File"C:\Users\s140041\Anaconda3\envs\testenv\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Users\s140041\Anaconda3\envs\testenv\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File"C:\Users\s140041\Anaconda3\envs\testenv\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File"C:\Users\s140041\Anaconda3\envs\testenv\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: DLL load failed: The specified module could not be found.
I have already done a LOT of troubleshooting:
I do not think the issue is path-related, Since Anaconda is my only installation of python on this machine, and the problem persists after a fresh installation of windows. I have not added anaconda to Path right now, since I just use the Anaconda prompt for all my conda related commands.
I do not think it is a problem with the environments, Problem exists on base/root environment of conda as well as on a new conda environment.
Problem is not system-related, was able to reproduce it on 2 seperate systems with specified version.
Problem is not PyCharm related, running python.exe from the root folder also gives the same error.
Uninstalling / reinstalling through conda doesn't work.
Conda does seem to look in the right library for the packages, checked this through print(sys.path) in python.exe, it returns the local library of anaconda where all it's default packages are installed.
Only when I uninstall using conda and re-install using pip everything works fine... Am i doing something wrong here, or is conda broken in this installation of Anaconda?
I just switched from a normal python/venv/pip to Anaconda/conda/environments, but I must say this is not really a warm welcome... Even though I heard that the conda packagement system is better than pip/venv.
UPDATE:
I filed a bug report on github, which can be found here.
https://github.com/conda/conda/issues/7833
Very clear discussion of what went wrong can be found in the bug-report on GitHub:
https://github.com/conda/conda/issues/7833
Summarized, using PyCharm with an unactivated environment is unsupported. So either use anaconda prompt, activate your environment and launch PyCharm from there, or re-install anaconda/mini-conda with the option "add-to-path" checked
Python was working file in my machine until yesterday night.
When I run my spyder I get,
An error occurred while starting the kernel
Error in sitecustomize; set PYTHONVERBOSE for traceback:
ImportError: DLL load failed: Access is denied.
If I try to install any module or import I get the below error,
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\__init__.py", line
22, in <module>
from pandas.compat.numpy import *
File "C:\ProgramData\Anaconda3\lib\site-
packages\pandas\compat\__init__.py", line 36, in <module>
from unicodedata import east_asian_width
ImportError: DLL load failed: Access is denied.
I found this is happening because of _socket.py , I tried changing _socket.pyd from another working machine but still, I could not fix this issue.
Please help, thanks in advance!
It appears that there are some other users having similar problems with kernel restart.
See here https://github.com/spyder-ide/spyder/issues/2812
Although it is difficult to see whether the above would help - maybe you could provide a way to replicate this problem?
In above thread the solution proposed is to run
conda update setuptools
An important element is always to check if you are in the correct environment or if you always work within an environment. This normally prevents many kernel and spyder issues as well as lost dependencies
You can create a new environment and reopen spyder from within the activated environment
conda create --name newEnv python=3.5
activate newEnv (WINDOWS)
source activate newEnv (MACOS/LINUX)
then
conda install anaconda
Additionally, what has helped me in the past is to go to tools-> reset spyder to factory defaults