28339

Module Not Found Error in Python 3.6 on windows command prompt

Question:

I have created a project like the below one:

project | | --package1 | | | -- <strong>init__py | --module1.py | | --package2 | --__init</strong>.py --module2.py

I want to import module1 into module2, (from package1 import module1)

In PyCharm everything is just working fine. But when I try to open the file "module2.py" from Windows10 command prompt I get ModuleNotFoundError:No module named 'module1' . I was looking for the solution but not a single one worked. I have set environment variable PYTHONPATH = I:\project\package1 I'm using python 3.6

Answer1:

By default, python only searches current directory. So you'll need to append the path a bit.

In module 2:

import sys sys.path.append('C:\PathTo\project\package1') import module1

That should fix the issue you were having.

Recommend

  • Module Not Found Error in Python 3.6 on windows command prompt
  • How to get current AppInfo in UWP environment
  • UWP Manifest issue / restricted capability / inputForegroundObservation
  • cx_Freeze ModuleNotFoundError: No module named 'codecs'
  • Execution of Python script with parameter and Windows10 doesn't work
  • ModuleNotFoundError: No module named 'pandas._libs.tslibs.timedeltas'
  • No module named NaiveBayes
  • Virtualenvwrapper does not initialize after updating Python to 3.6
  • Jupyter Notebook: no module named pandas
  • R read ORC file from S3
  • surprising result coming in java servlet
  • Pycharm html indentation
  • cython compiles but no pyd files are generated
  • ROWDEPENDENCIES Overhead in Oracle
  • ERROR:gpu_process_transport_factory.cc(1007)] Lost UI shared context : while initializing Chrome bro
  • ModuleNotFoundError: No module named 'matplotlib'
  • Is it always a good idea to import very specifically in Python?
  • Django simple Captcha “No module named fields” error
  • Why does access(2) check for real and not effective UID?
  • Meteor helpers not available in Angular template
  • Sony Xperia Z Tablet not found by adb
  • How to recover from a Spring Social ExpiredAuthorizationException
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Can I make an Android app that runs a web view in Chrome 39?
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • How can I estimate amount of memory left with calling System.gc()?
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Matrix multiplication with MKL
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • using HTMLImports.whenReady not working in chrome
  • Hits per day in Google Big Query
  • coudnt use logback because of log4j
  • Memory offsets in inline assembly
  • File not found error Google Drive API
  • LevelDB C iterator
  • Linking SubReports Without LinkChild/LinkMaster
  • Converting MP3 duration time