0

This code worked on Friday without problems and still running on a colleagues laptop, but I cannot run it anymore. As you can see in the screenshot, my editor doesnt find some moduls anymore and the pylint Error "E0401: Unable to import" occurs. The missing file exists in the folder Settings, as you can see in the Explorer on the left side.

Today I deactivated/activated pylint, reinstalled vs code and python, added the init.py to Settings folder, tried the same code in eclipse, modified the Path enviroment variable and created the PYTHONPATH enviroment variable. All this with no success:/

I am greatful for each hint, which provide me to solve this problem.

enter image description here

The error output as text:

    Windows PowerShell
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.

PS C:\Users\Evgenij\Desktop\Desktop\Eth_Test_Dev> & C:/Python27/python.exe c:\Users\Evgenij\Desktop\Desktop\Eth_Test_Dev\Code\__TC__Template.py
Traceback (most recent call last):
  File "c:\Users\Evgenij\Desktop\Desktop\Eth_Test_Dev\Code\__TC__Template.py", line 36, in <module>
    from Lib.IHR_EthApi import EthApi as ETH
  File "c:\Users\Evgenij\Desktop\Desktop\Eth_Test_Dev\Code\Lib\IHR_EthApi.py", line 6, in <module>
    from IHR_GeneralApi import GeneralApi as SYS
  File "c:\Users\Evgenij\Desktop\Desktop\Eth_Test_Dev\Code\Lib\IHR_GeneralApi.py", line 4, in <module>
    import IHR_TestSuiteConfig.py
ImportError: No module named IHR_TestSuiteConfig.py
PS C:\Users\Evgenij\Desktop\Desktop\Eth_Test_Dev>
2
  • 4
    Please use text for your question and error output rather than a screenshot. Images are not searchable so are unlikely to be useful for any future reference Commented Feb 27, 2018 at 14:17
  • Thx for the hint. I added some more information and the error output. Tell me when you need more details. Commented Feb 28, 2018 at 9:01

1 Answer 1

1

In your code you have the line:

import IHR_TestSuiteConfig.py

That won't work because you don't specify modules to import by file name but by module name, e.g.:

import IHR_TestSuiteConfig

But looking at your screenshot you have a bigger issue of the code being kept in a Settings directory at the same level as your Lib directory containing the code you are importing into.

You need to either anchor all of your code up a level so you can do:

from ..Settings import IHR_TestSuiteConfig

Or you need to manipulate your PYTHONPATH environment variable to put Settings directly on to sys.path (in VS Code you can create a .env file to do this, but it won't' affect running Python from the terminal, only when VS Code runs e.g. Pylint).

Sign up to request clarification or add additional context in comments.

1 Comment

Thaks for you Answer! There was really a bigger issue, but i think it was solved as i added the Settings folder to Path and PYTHONPATH as you said. Now i working on the next problem, but that will be another topic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.