Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mkvirtualenv results in error: The system cannot find the path specified #14

Closed
siddhion opened this issue Apr 20, 2012 · 11 comments
Closed

Comments

@siddhion
Copy link

I installed virtualenvwrapper-win in an elevated prompt with the following commands

pip install virtualenvwrapper-win
pyassoc

but when I try running

mkvirtualenv test

I get

 The system cannot find the path specified.
 The system cannot find the path specified.
 The system cannot find the path specified.

Yes it prints that line out three times. How come this is happening?

@davidmarble
Copy link
Owner

Can you give me some more details? Which version of Windows? And is it 32 or 64 bit? If it's a version with UAC, what level of UAC are you running with? Is your user an administrator or regular user?

@davidmarble
Copy link
Owner

Also, one thing that would be helpful is to open the pyassoc.bat file and remove the first line (echo off) so we can see where the script dies.

@davidmarble
Copy link
Owner

Oh, and type "where python.exe" in a command prompt and share the result. Also, type "path" in a command prompt and share the result.

@siddhion
Copy link
Author

I am using Windows Vista Home Premium 64bit and am running cmd.exe (command prompt) as Administrator.

After taking out @echo off in pyassoc.bat I run pyassoc in command prompt and get the following

C:\>pyassoc

C:\>if defined VIRTUAL_ENV (call "\Scripts\deactivate.bat" )

C:\>if defined PYTHONHOME (goto MAIN )

C:\>REM Detect if the user is running in elevated mode.

C:\>REM Relies on requiring admin privileges to read the LOCAL SERVICE accou
nt reg key.

C:\>reg query "HKU\S-1-5-19"  1>NUL 2>NUL

C:\>assoc .pyc=Python.CompiledFile  1>NUL 2>NUL

C:\>ftype Python.CompiledFile="C:\env\Scripts\Scripts\python.bat" "%1" %*  1
>NUL 2>NUL

C:\>assoc .py=Python.File  1>NUL 2>NUL

C:\>ftype Python.File="C:\env\Scripts\Scripts\python.bat" "%1" %*  1>NUL 2>N
UL

    .py files will launch with "C:\env\Scripts\Scripts\python.bat" "%1" %*

Result of running where python.exe is

C:\>where python.exe
C:\Python27\python.exe
C:\env\Scripts\python.exe

Let me know if you need any more info.

@davidmarble
Copy link
Owner

Looks like you're trying to run this while a virtualenv is already activated. That's why all that paths are wrong. Run pyassoc when NO virtualenv is activated.

@siddhion
Copy link
Author

To my knowledge there was no virtualenv activated or else I would have seen the (envname) in front of the current command prompt's line. Like in the following:

(newenv) C:\Users\username\Desktop\newenv>

Right?

And if I am wrong then there must be a hidden, activated virtualenv somewhere. If that is the case then how do I make sure no virtualenv is activated?

@davidmarble
Copy link
Owner

The fact that you got this:

C:\>where python.exe
C:\Python27\python.exe
C:\env\Scripts\python.exe

means that there are two python.exe runtimes found in your PATH. Type path and you should see this. The output of pyassoc above is giving you errors because it thinks your main python installation (PYTHONHOME environment variable that it tries to find out itself if it's not already set on your system) is in C:\env\Scripts\python.exe.

@siddhion
Copy link
Author

Ok but if I take out the C:\env\Scripts; from my system path then all the other script commands in C:\env\Scripts; like activate and deactivate won't work. Right? So what should I do?

@davidmarble
Copy link
Owner

Sounds like you're not familiar with how virtualenv works, upon which virtualenvwrapper-win is built. You should read up on the virtualenv package. I'll give you a short explanation for Windows because I'm good like that...

When you create a new virtual environment using virtualenv (virtualenvwrapper-win calls the virtualenv commands for you when you use mkvirtualenv), a few scripts are created for activating and deactivating that specific virtual environment. You can see these in {path to virtualenv}\Scripts -- activate.bat, deactivate.bat, and Powershell versions ending in .ps.

When you activate that virtual environment with activate.bat, which you would call manually if you didn't install virtualenvwrapper-win, and which is called automatically when you use the command workon from virtualenvwrapper-win, the additional executable paths and python library paths for that virtual environment are added automatically to your PATH and PYTHONPATH. You should not add anything to PATH and PYTHONPATH yourself for working with virtualenvs. These are temporary changes for the command prompt you have open. If you call deactivate, it removes those additional paths from the environment variables. Or if you just close the window, the changes were temporary anyway so don't matter.

@Prakki1239
Copy link

venv\Scripts\activate.bat

when i run this command in my command prompt

I am getting "the system cannot find the path specified" please help me @davidmarble

Thanks in advance!!

@sujeet-agrahari
Copy link

sujeet-agrahari commented May 6, 2018

I was getting the same error. Actually, I had installed 'vritualenvwrapper -win" inside another virtual environment not globally.
Deactivate any virtualenv if you are running. Open CMD, uninstall that package pip uninstall virtualenvwrapper-win and install it again pip install virtualenvwrapper-win, It will work!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants