PyCharm Python Console fails to import variables in setup.py

Answered

I have a setup.py file in my project directory, in which I have only stored a variable that contains the root directory path. The file looks like:

import os

ROOT_DIR = os.path.dirname(os.path.realpath(__file__))

I then import this variable in other files, using:

from setup import ROOT_DIR

When I run this line in the Python Console in PyCharm, I get the following error:

Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\path_to_pycharm\JetBrains\PyCharm Community Edition 2018.1.1\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 19, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\path_to_pycharm\JetBrains\PyCharm Community Edition 2018.1.1\helpers\pydev\setup.py", line 87, in <module>
data_files.append(('pydevd_attach_to_process', [os.path.join('pydevd_attach_to_process', f) for f in os.listdir('pydevd_attach_to_process') if accept_file(f)]))
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'pydevd_attach_to_process'

 

The error is not returned if I run the line using another python console

How can I fix the PyCharm Console?

(I am using PyCharm Community Edition 2018.1.1 on Windows 7.)

0
2 comments

Hi Ed_Ab, PyCharm tweaks PYTHONPATH and unfortunately it results in this bug. I created a ticket in our bug tracker: PY-30480.

1
Avatar
Permanently deleted user

Thank you Pavel!

0

Please sign in to leave a comment.