0

I have the next problem with Python 2.7.3:

There's little project with the next structure (see at the end); through virtual environment Python doesn't see a module, but before it did.

I've already tried rebooting and reinstalling virtualenv directory—nothing. Also, if I run the necessary script file out of any virtual environment (using ipython), it finds that module. I've been looking for the problem all night. Can anybody help me? For example, I'm trying to run the script from delete_ME_after.py (inside of it there's importing module base.config_parser).

Also, I've already set path to this project to PYTHONPATH—also nothing works.

enter image description here

Jens
  • 8,423
  • 9
  • 58
  • 78
  • .....what? Uh, if my parsing of your question is right, "that's the point of virtualenv", but if my parsing is wrong....uh, wut? – NightShadeQueen Jul 16 '15 at 01:35
  • What module is missing? What's the error message? Which module installer do you use, [pip](https://pypi.python.org/pypi/pip)? Did you try to install the module in your virtual environment? – Jens Jul 16 '15 at 01:36
  • yeap, I also think this's virtualenv's problem, because without it - everything OK – user3780183 Jul 16 '15 at 01:37
  • Error: standart ImportError: no module is found bla bla bla... I use pip. I'm trying get access to base.config_parser from delete_ME_after.py – user3780183 Jul 16 '15 at 01:38
  • Please place the __whole__ error, where it came from (stacktrace), and preferably the page should be in english. also: why was hiding a file name in the project neccesary? – CristiFati Jul 16 '15 at 01:47
  • @Jens: yeah, ../ in picture is parent directory called, for example, upDir; and yes, I've assigned ~/upDir to PYTHONPATH and then I've export it. – user3780183 Jul 16 '15 at 01:51
  • The `base` module is missing, but from your image it seems to be in the parent directory. You pointed your `PYTHONPATH` at the parent too? In your image, I don't see the rest of the virtual environment, that would help. Somehow, [this question](http://stackoverflow.com/questions/17525112/importerror-no-module-named-base) looks similar... – Jens Jul 16 '15 at 01:52
  • @CristiFati : here's link to all terminal's output: http://rghost.ru/6bRCcj4zM – user3780183 Jul 16 '15 at 01:54
  • @Jens : here's additional info (link to pic from terminal): http://rghost.ru/6bRCcj4zM – user3780183 Jul 16 '15 at 01:56
  • What's inside `config_parser.py`, is `conf` missing there? More information is [here](https://docs.python.org/2/tutorial/modules.html). – Jens Jul 16 '15 at 02:29
  • @Jens : just one class that parses json file, and after its implementation there's `conf = ConfigParser()` – user3780183 Jul 16 '15 at 02:32
  • Might be weird, but try replacing `~` in `PYTHONPATH` with the actual full path to your home directory, i.e. `export PYTHONPATH=/my/home/dir/smm`. – Jens Jul 16 '15 at 02:34
  • @Jens : wow, it works! unbelievable! Just append `/home/nikolay/smm` to `PYTHONPATH` and there's no more `ImportError`. Thank you very much. – user3780183 Jul 16 '15 at 02:40
  • Ok good :) Some shells don't really expand `~` in all circumstances, which leaves the path broken. Always use `$HOME` or the full path, and avoid `~`. If this solved your question, please accept the answer below. – Jens Jul 16 '15 at 20:51

1 Answers1

2

As it turns out, the above PYTHONPATH variable contains a tilde ~ which isn't expanded to the full home directory as expected. See here for more information.

Use one of the following instead:

export PYTHONPATH=/path/to/home/smm
export PYTHONPATH=${HOME}/smm
Community
  • 1
  • 1
Jens
  • 8,423
  • 9
  • 58
  • 78