Run Import-Module virtualenvwrapper using powershell

Asked 2 years ago, Updated 2 years ago, 90 views

I started studying Data Visualization using poewrshell.
Python version is 2.7
Windows uses 8.1.

My system environment variable path is as follows.

c:\python27\;c:\python27\scripts;c:\python27\tools\scripts;C:\Program Files (x86)\Common Files\Apple\Apple Application Support;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Common Files\RoxioShared\DLLShared\; C:\Program Files (x86)\Common Files\RoxioShared\OEM\12.0\DLLShared\; C:\Program Files (x86)\Roxio 2010\OEM\AudioCore\; C:\Program Files (x86)\Brackets\command; C:\Qram Time (Qram Time (QickTime)

US>You are currently in a state where your computer environment is aligned with the guidance (http://newcoder.io/begin/setup-your-machine/ #windows).
The installation of powershell, python, git, pip, virtualenv, virtualenvwrapper-powershell went well (with help).
type: I stuck in Import-Module virtualenvwrapper...(The virtualenvwrapper-powershell installation is complete...)

When I type Import-Module virtualenvwrapper, I get the following error message:

PSC:\python27>Import-Module virtualenvwrapper
Import-Module: The specified module 'virtualenvwrapper' was not loaded because no valid module file was found in any
module directory
Atline:1 char:1
+ Import-Module virtualenvwrapper
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo: ResourceUnavailable: (virtualenvwrapper: String) Import-Module, FileNotFoundException
    + Fully QualifiedErrorId: Modules_ModuleNotFound, Microsoft.PowerShell.Commands.ImportModuleCommand

Also, you pointed out that saving a module in a folder with the same name as that module or using .psm1 as a command might work. ((https://stackoverflow.com/questions/31096527/import-module-virtualenvwrapper/31097136#31097136))

 C:\Python27\virtualenvwrapper

virtualenvwrapper.psm1 is deployed on the and
I tried to run Import-Module virtualenvwrapper, but the error message was the same as above.

Import-Module: The specified module 'virtualenvwrapper' was not loaded because no valid module file was found in any
module directory
Atline:1 char:1
+ Import-Module virtualenvwrapper
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo: ResourceUnavailable: (virtualenvwrapper: String) Import-Module, FileNotFoundException
    + Fully QualifiedErrorId: Modules_ModuleNotFound, Microsoft.PowerShell.Commands.ImportModuleCommand

I also tried Import-Module virtualenvwrapper.psm1 and got the following error message...

Import-Module: The specified module 'virtualenvwrapper.psm1' was not loaded because no valid module file was found in
any module directory.
Atline:1 char:1
+ Import-Module virtualenvwrapper.psm1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo: ResourceUnavailable: (virtualenvwrapper.psm1:String) Import-Module, FileNotFoundExcept
   ion
    + Fully QualifiedErrorId: Modules_ModuleNotFound, Microsoft.PowerShell.Commands.ImportModuleCommand

I also tried Import-Module C:\Python27\virtualenvwrapper\virtualenvwrapper.psm1 and got the following error message...

PSC:\python27>Import-Module C:\Python27\virtualenvwrapper\virtualenvwrapper.psm1
Import-Module: The specified module'C:\Python27\virtualenvwrapper\virtualenvwrapper.psm1'was not loaded cause no
valid module file was found in any module directory.
Atline:1 char:2
+  Import-Module C:\Python27\virtualenvwrapper\virtualenvwrapper.psm1
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo: ResourceUnavailable: (C:\Python27\vir...envwrapper.psm1:String) Import-Module, FileNot
   FoundException
    + Fully QualifiedErrorId: Modules_ModuleNotFound, Microsoft.PowerShell.Commands.ImportModuleCommand

You can also refer to this page (https://stackoverflow.com/questions/31035903/installing-virtualenvwrapper-powershell-in-windows-8-1-import-module-failing),
Create a folder called WindowsPowerShell\Modules in the documentation and
write the VirtualEnvWrapper directory from the virtualenvwrapper-powershell bitbucket. I installed it in the Modules folder, ran Set-ExecutionPolicy Unrestricted, and then ran Import-Module virtualenvwrapper, but I still got an error.

The error message is as follows:

PSC:\python27>Set-ExecutionPolicy Unrestricted

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy weight export
You to the security risks described in the about_Execution_Policies help topic at
http://go.microsoft.com/fwlink/?LinkID=135170.Do you want to change the execution policy?
[Y] Yes [N] No [S] Suspend [?] Help(default is "Y"):y
PSC:\python27>Import-Module virtualenvwrapper
Import-Module: The specified module 'virtualenvwrapper' was not loaded because no valid module file was found in any
module directory
Atline:1 char:1
+ Import-Module virtualenvwrapper
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo: ResourceUnavailable: (virtualenvwrapper: String) Import-Module, FileNotFoundException
    + Fully QualifiedErrorId: Modules_ModuleNotFound, Microsoft.PowerShell.Commands.ImportModuleCommand

I apologize for the long delay.
If anyone has any ideas, I would appreciate it if you could help me.

★Addition★
Dear BLUEPIXY, the following is a new error message.

PSC:\windows\system32>Import-Module virtualenvwrapper

Security warning
Run only scripts that you trust. While scripts from the Internet can be used, this script can potentially harm your
computer.If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message.Do you want to run
C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\virtualenvwrapper.psm1?
[D] Do not run [R] Run Once [S] Suspend [?] Help (default is "D")—r
At C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\virtualenvwrapper.psm1:48 char:3
+ if ["$VIRTUALENVWRAPPER_PYTHON"="]
+   ~
Missing'('after' if' in statement.
At C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\virtualenvwrapper.psm1:48 char:5
+ if ["$VIRTUALENVWRAPPER_PYTHON"="]
+     ~
Missing type name after '['.
At C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\virtualenvwrapper.psm1:54 char:3
+ if ["$VIRTUALENVWRAPPER_VIRTUALENV"="]
+   ~
Missing'('after' if' in statement.
At C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\virtualenvwrapper.psm1:54 char:5
+ if ["$VIRTUALENVWRAPPER_VIRTUALENV"="]
+     ~
Missing type name after '['.
At C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\virtualenvwrapper.psm1:59 char:38
+ virtualenvwrapper_derive_workon_home(){
+                                      ~
An expression was expected after'('.
At C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\virtualenvwrapper.psm1:64 char:7
+     if ["$workon_home_dir"="]
+       ~
Missing'('after' if' in statement.
At C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\virtualenvwrapper.psm1:64 char:9
+     if ["$workon_home_dir"="]
+         ~
Missing type name after '['.
At C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\virtualenvwrapper.psm1:71 char:7
+     if echo "$workon_home_dir" | (unset GREP_OPTIONS;\grep'^[^/~]'>/dev/null...
+       ~
Missing'('after' if' in statement.
At C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\virtualenvwrapper.psm1:71 char:53
+     if echo "$workon_home_dir" | (unset GREP_OPTIONS;\grep'^[^/~]'>/dev/null...
+                                                     ~
Missing closing') 'in expression.
At C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\virtualenvwrapper.psm1:71 char:34
+     if echo "$workon_home_dir" | (unset GREP_OPTIONS;\grep'^[^/~]'>/dev/null...
+                                  ~~~~~~~~~~~~~~~~~~~
Expressions are only allowed as the first element of a pipeline.
Not all parse errors were reported. Correct the reported errors and try again.
    + CategoryInfo:ParserError:(:)[], ParentContainsErrorRecordException
    + Fully QualifiedErrorId—MissingOpenParenthesisInIfStatement

Import-Module: The specified module 'virtualenvwrapper' was not loaded because no valid module file was found in any
module directory
Atline:1 char:1
+ Import-Module virtualenvwrapper
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo: ResourceUnavailable: (virtualenvwrapper: String) Import-Module, FileNotFoundException
    + Fully QualifiedErrorId: Modules_ModuleNotFound, Microsoft.PowerShell.Commands.ImportModuleCommand

★Addition★

The following is the new error message.
The error message is much shorter!!

PSC:\windows\system32>Import-Module virtualenvwrapper

Security warning
Run only scripts that you trust. While scripts from the Internet can be used, this script can potentially harm your
computer.If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message.Do you want to run
C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\virtualenvwrapper.psm1?
[D] Do not run [R] Run Once [S] Suspend [?] Help (default is "D")—r
Switch-DefaultPython: The term 'Switch-DefaultPython' is not recognized as the name of a cmdlet, function, script
file, or operable program.Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\virtualenvwrapper.psm1:16 char:1
+ Switch - DefaultPython
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo: ObjectNotFound: (Switch-DefaultPython: String) [ ], CommandNotFoundException
    + Fully QualifiedErrorId—CommandNotFoundException

Initialize: The term 'Initialize' is not recognized as the name of a cmdlet, function, script file, or operable
program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\virtualenvwrapper.psm1:334 char:1
+ Initialize
+ ~~~~~~~~~~
    + CategoryInfo: ObjectNotFound: (Initialize: String) [ ], CommandNotFoundException
    + Fully QualifiedErrorId—CommandNotFoundException

★Additional postscript★

Below is the error message
Looking at the message, it seems that many things are not automated.

PSC:\windows\system32>Import-Module virtualenvwrapper

Security warning
Run only scripts that you trust. While scripts from the Internet can be used, this script can potentially harm your
computer.If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message.Do you want to run
C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\virtualenvwrapper.psm1?
[D] Do not run [R] Run Once [S] Suspend [?] Help (default is "D")—r

Security warning
Run only scripts that you trust. While scripts from the Internet can be used, this script can potentially harm your
computer.If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message.Do you want to run C:\Users\SomaSoma\Documents\WindowsPowerShell\Modules\Win\Win.psm1?
[D] Do not run [R] Run Once [S] Suspend [?] Help (default is "D")—r
Initialize: The term 'Initialize' is not recognized as the name of a cmdlet, function, script file, or operable
program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\virtualenvwrapper.psm1:334 char:1
+ Initialize
+ ~~~~~~~~~~
    + CategoryInfo: ObjectNotFound: (Initialize: String) [ ], CommandNotFoundException
    + Fully QualifiedErrorId—CommandNotFoundException

★@Addition★
It looks like it's finally succeeded.As shown in the message below, this error is only caused by TabExpansion, which seems to be negligible!
This means that the execution of "Import-Module virtualenvwrapper" was successful.
However, there is no sign of 'success' in the message.
Is this really a success?

PSC:\windows\system32>Import-Module virtualenvwrapper

Security warning
Run only scripts that you trust. While scripts from the Internet can be used, this script can potentially harm your
computer.If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message.Do you want to run C:\Users\SomaSoma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\support.psm1?
[D] Do not run [R] Run Once [S] Suspend [?] Help (default is "D")—r

Security warning
Run only scripts that you trust. While scripts from the Internet can be used, this script can potentially harm your
computer.If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message.Do you want to run C:\Users\SomaSoma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\win.psm1?
[D] Do not run [R] Run Once [S] Suspend [?] Help (default is "D")—r

Security warning
Run only scripts that you trust. While scripts from the Internet can be used, this script can potentially harm your
computer.If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message.Do you want to run
C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\VirtualenvWrapperTabExpansion.psm1?
[D] Do not run [R] Run Once [S] Suspend [?] Help (default is "D")—r
Get-Content: Cannot find path 'Function:\TabExpansion' because it does not exist.
At C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\VirtualenvWrapperTabExpansion.psm1:12
char —21
+ $_oldTabExpansion=Get-Content Function:TabExpansion
+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo: ObjectNotFound: (Function:\TabExpansion: String) Get-Content, ItemNotFoundException
    + Fully QualifiedErrorId: PathNotFound, Microsoft.PowerShell.Commands.GetContentCommand


Security warning
Run only scripts that you trust. While scripts from the Internet can be used, this script can potentially harm your
computer.If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message.Do you want to run
C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\virtualenvwrapper.psm1?
[D] Do not run [R] Run Once [S] Suspend [?] Help (default is "D")—r

Security warning
Run only scripts that you trust. While scripts from the Internet can be used, this script can potentially harm your
computer.If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message.Do you want to run
C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\Extensions.Project.ps1?
[D] Do not run [R] Run Once [S] Suspend [?] Help (default is "D")—r

Security warning
Run only scripts that you trust. While scripts from the Internet can be used, this script can potentially harm your
computer.If you trust this script, use the Unblock-File cmdlet to allow the script to run without this warning
message.Do you want to run
C:\Users\Soma\Documents\WindowsPowerShell\Modules\virtualenvwrapper\Extensions.UserScripts.ps1?
[D] Do not run [R] Run Once [S] Suspend [?] Help (default is "D")—r
PSC:\windows\system32>

Also, Get-Command* virtualenv*

When you run , you see the following and it still looks like it was successful.

PSC:\windows\system32>Get-Command* virtualenv*

CommandTypeNameModuleName
-----------     ----                                               ----------
Alias cdvirtualenv->VirtualEnvWrapper
Aliascpvirtualenv->VirtualEnvWrapper
Aliaslsvirtualenv->VirtualEnvWrapper
Alias mkvirtualenv - > VirtualEnvWrapper
Alias rmvirtualenv->VirtualEnvWrapper
Function add_posh_to_virtualenv VirtualEnvWrapper
Function add2 virtualenv VirtualEnvWrapper
Function CDIntoVirtualEnvironment VirtualEnvWrapper
Function Copy - VirtualEnvironment VirtualEnvWrapper
Function GetVirtualEnvCompletions VirtualEnvWrapper
Function GetVirtualEnvDataVirtualEnvWrapper
Function Get - VirtualEnvironment VirtualEnvWrapper
Function LetVirtualEnvsThru VirtualEnvWrapper
Function LooksLikeAVirtualEnv VirtualEnvWrapper
Function NewVirtualEnvDataVirtualEnvWrapper
Function New - VirtualEnvironment VirtualEnvWrapper
Function Remove - VirtualEnvironment VirtualEnvWrapper
Function Set - VirtualEnvironment VirtualEnvWrapper
Function show virtualenv VirtualEnvWrapper
Application add2 virtualenv.bat
Application cdvirtualenv.bat
Application lsvirtualenv.bat
Application mkvirtualenv.bat
Application rmvirtualenv.bat
Application virtualenv.exe
Application virtualenv-3.4.exe
Application virtualenv-clone.exe

python powershell

2022-09-30 14:26

1 Answers

The module must be located in the location indicated by the module path.
The user-level (module by user) path of a standard script module is
C:\Users\UserName\Documents\WindowsPowerShell\Modules
Yes. (UserName is each username)
In that sense, the correct directory to place the module is the last one.
In other words, create the WindowsPowerShell\Modules folder in the document folder
In the Modules folder, create the virtualenvwrapper folder for the folder virtualenvwrapper.psm1 and place the virtualenvwrapper.psm1 file there.
So,
I think you should run Import-Module virtualenvwrapper.
(Version 3 and later should load automatically at startup)


2022-09-30 14:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.