I have a code in Python 2.7 write using the IDLE PyCharm on Windows 7 OS. Running inside the IDLE i have no problem to import all modules. When i run with the command prompt of windows i get this error message:
C:\Users\samsung>C:\PythonScript\TOOL.py
Traceback (most recent call last):
File "C:\PythonScript\TOOL.py", line 5, in <module
>
import ogr
ImportError: No module named ogr
I can import this module with the IDLE without problem.
Related
I have pygame and numpy in the same folder. I can import pygame, but I can only import numpy in the terminal, not even in the IDLE. If I try to import numpy anywhere else, I get this message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'
I can also still import pygame into the terminal. Also, python in the terminal is version 3.7.5, but in the IDLE it's 3.6.6. Not sure if that's related.
All of my modules are in the default path folder.
I am facing the following error:
import numpy
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import numpy
File "C:\Users\saikr\Python38\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\Users\saikr\Python38\lib\site-packages\numpy\_distributor_init.py", line 22, in <module>
for filename in glob.glob(os.path.join(libs_dir,
AttributeError: module 'glob' has no attribute 'glob'
this error is occurred in IDE
C:\Users\saikr>numpy
'numpy' is not recognized as an internal or external command,
operable program or batch file.
this error occurred in cmd
How can it be resolved?
Try this::
Type
python in cmd
then type
import numpy as np
It is quite likely your IDE creates a Virtual Env for each new project you start (linked to pep 405 for more details about venv).
You can use pip freeze from your IDE in order to see all installed packages in your current environment
The second error occurs because you are calling a python command from cmd. You need to call python command before your code in order to run python commands from cmd
I'm using PyCharm for a project with the following file hierarchy:
And I'm running main.py in PyCharm with the following configurations:
Working Directory: /Users/me/longpath/project/amlproject/pca_mixtures.
When I try to run in terminal, it fails:
~/longpath/project/amlproject/pca_mixtures$ python main.py
Traceback (most recent call last):
File "main.py", line 2, in <module>
from pca_mixtures.funcs import PCAMixture
ModuleNotFoundError: No module named 'pca_mixtures'
and nothing changes if I jump up to the parent folder:
~/longpath/project/amlproject$ python pca_mixtures/main.py
Traceback (most recent call last):
File "pca_mixtures/main.py", line 2, in <module>
from pca_mixtures.funcs import PCAMixture
ModuleNotFoundError: No module named 'pca_mixtures'
The reason for using from pca_mixtures.funcs import PCAMixture instead of just from funcs import PCAMixture was so that PyCharm would recognize the import and not red-underline it, as I've described here. Now, it seems that this has lead to me not being able to run the project in the terminal.
How would you handle this? I want to be able to run it in the terminal because the PyCharm output is not fully sequential (error messages output before program output) which is annoying when debugging.
I'm trying to learn webscraping and when running a script using the run command on Windows, it shows an error in cmd:
Traceback (most recent call last):
File "c:\users\user\MyPythonScripts\k.py", line 1, in <module>
import bs4, requests
ModuleNotFoundError: No module named 'bs4'
It only happens using the run command, the script fine on the PyCharm IDE though.
I'm trying to learn xlwings for in Windows 7 but I get the following error when importing the xlwings module in python IDLE
>>> import xlwings
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import xlwings
ImportError: No module named 'xlwings'
>>>
I installed Python using the Anaconda distribution and path variable correctly includes the site-packages
C:\Users\xxx\Anaconda3\Lib\site-packages;
I'm using Excel 2013. Any ideas?