pghilardi / atom-python-virtualenv

Python virtualenv support for Atom
MIT License
16 stars 6 forks source link

VIRTUAL_ENV is not set #48

Open Ilis opened 3 years ago

Ilis commented 3 years ago

After upgrade python from 3.8 to 3.9 atom-python-virtualenv does not working.

When I run program under atom it can't find installed modules:

Traceback (most recent call last):
  File "C:\Users\ilis\PyProj\hyperskill\test_venv.py", line 12, in <module>
    from nltk.corpus import brown
ModuleNotFoundError: No module named 'nltk'

When I run it with PowerShell it's OK.

I rewritten my program to test a case:

import os
import sys

for e, v in os.environ.items():
    if "hyper" in v:
        print(e, v)

for path in sys.path:
    print(path)

from nltk.corpus import brown

print(brown.categories())

and find out a difference: atom output is:

PATH C:\Users\ilis\PyEnvs\hyperskill\Scripts;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\PowerShell\7\;C:\Users\ilis\AppData\Local\Programs\Python\Python39\Scripts\;C:\Users\ilis\AppData\Local\Programs\Python\Python39\;C:\Users\ilis\AppData\Local\Programs\Python\Launcher\;C:\Users\ilis\AppData\Local\Microsoft\WindowsApps;C:\Users\ilis\AppData\Local\atom\bin;C:\Users\ilis\AppData\Local\Programs\Microsoft VS Code\bin;
C:\Users\ilis\PyProj\hyperskill
c:\users\ilis\appdata\local\programs\python\python39\python39.zip
c:\users\ilis\appdata\local\programs\python\python39\DLLs
c:\users\ilis\appdata\local\programs\python\python39\lib
c:\users\ilis\appdata\local\programs\python\python39
c:\users\ilis\appdata\local\programs\python\python39\lib\site-packages
Traceback (most recent call last):
  File "C:\Users\ilis\PyProj\hyperskill\test_venv.py", line 12, in <module>
    from nltk.corpus import brown
ModuleNotFoundError: No module named 'nltk'

and PowerShell output is:

(hyperskill) C:\Users\ilis\PyProj\hyperskill>py test_venv.py
ENV_PROMPT (hyperskill)
PATH C:\Users\ilis\PyEnvs\hyperskill\Scripts;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\PowerShell\7\;C:\Users\ilis\AppData\Local\Programs\Python\Python39\Scripts\;C:\Users\ilis\AppData\Local\Programs\Python\Python39\;C:\Users\ilis\AppData\Local\Programs\Python\Launcher\;C:\Users\ilis\AppData\Local\Microsoft\WindowsApps;C:\Users\ilis\AppData\Local\atom\bin;C:\Users\ilis\AppData\Local\Programs\Microsoft VS Code\bin
PROMPT (hyperskill) $P$G
VIRTUAL_ENV C:\Users\ilis\PyEnvs\hyperskill
C:\Users\ilis\PyProj\hyperskill
c:\users\ilis\appdata\local\programs\python\python39\python39.zip
c:\users\ilis\appdata\local\programs\python\python39\DLLs
c:\users\ilis\appdata\local\programs\python\python39\lib
c:\users\ilis\appdata\local\programs\python\python39
C:\Users\ilis\PyEnvs\hyperskill
C:\Users\ilis\PyEnvs\hyperskill\lib\site-packages
C:\Users\ilis\PyProj\hyperskill
['adventure', 'belles_lettres', 'editorial', 'fiction', 'government', 'hobbies', 'humor', 'learned', 'lore', 'mystery', 'news', 'religion', 'reviews', 'romance', 'science_fiction']

Package changes only the PATH environment C:\Users\ilis\PyEnvs\hyperskill is a venv directory But it doesn't set the VIRTUAL_ENV environment and python can't find module for import.

Please, help me to solve this problem.

Ilis commented 3 years ago

I've removed 3.9 and get back to 3.8.5, reinstalled venv with virtualenvwrapper, and everything get back.

Then I've upgraded 3.8.5 to 3.8.6 and upgraded venv for my project. It broken down again.

I've made new 3.8.6 virtualenv for project with virtualenvwrapper and now it work.

So, the way to broke things it is to upgrade virtualenv with: py -m venv --upgrade C:\Users\ilis\PyEnvs\hyperskill

diff3 commented 3 years ago

if you just want it to work, but not really fix anything you can always open virtualenv-manage.coffee and change
@path = process.env.VIRTUAL_ENV to @path = "path to my virtualenv folder" or use WORKON_HOME value as path to virtualenv. @path = atom.config.get('atom-python-virtualenv.getVirtualEnvsFromHome')

Ilis commented 3 years ago

if you just want it to work

Thank you for your proposal! The problem is I want to change my virtualenvs from one to another, and they detected well, they are taken from virtualenvwrapper environment, but selecting one, that was upgraded, is not working.