5

I made virtualenv called bitcoin_notifications.py and I'm going to activate it but:

PS C:\Users\piotr> bitcoin_notifications\activate.ps1
bitcoin_notifications\activate.ps1 : ```The module
'bitcoin_notifications' could not be loaded. For more information, run
'Import-Module bitcoin_notifications'.``` At line:1 char:1
+ bitcoin_notifications\activate.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (bitcoin_notifications\activate.ps1:String) [],
CommandNotFoundException
    + FullyQualifiedErrorId : CouldNotAutoLoadModule

In the result shared before we read the module could not be loaded and if one wants more info to run another specific command.

Once I run it,

PS C:\Users\piotr> ```Import-Module bitcoin_notifications

Import-Module : The specified module 'bitcoin_notifications' was not
loaded because no valid module file was found in any module
directory.``` At line:1 char:1
+ Import-Module bitcoin_notifications
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (bitcoin_notifications:String) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : ```Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand```

we can understand there's no module in that directory. I just want to activate the virtualenv. How can I do that?

EDIT: I was copying the method of creating new venv:

  1. pip install virtualenv
  2. mkdir Environments
  3. cd !$
  4. virtualenv bitcoin_notifications
  5. bitcoin_notifications\activate.ps1
wovano
  • 4,543
  • 5
  • 22
  • 49
  • The error message indicates that the `bitcoin_notifications` module could not be found. Is the module installed correctly? – HAL9256 Apr 17 '19 at 19:23
  • Honestly, I was copying the method of creating new venv: 1. ```pip install virtualenv``` 2. ```mkdir Environments``` 3. ```cd !$``` 4. ```virtualenv bitcoin_notifications``` 5. ```bitcoin_notifications\activate.ps1``` –  Apr 18 '19 at 07:30

2 Answers2

3

The first lines from activate.ps1 seem to mention the solution:

# This file must be dot sourced from PoSh; you cannot run it
# directly. Do this: . ./activate.ps1

So, the following should work (step 4 and 5 from your method — note that step 5 was missing the dot!):

virtualenv bitcoin_notifications
. .\bitcoin_notifications\Scripts\activate.ps1

NB: Your question mentions venv but actually is about virtualenv. Note that these are two similar but different tools. Also, in step 5 you were missing the "Scripts" part. Maybe that was a copy-paste error when writing the question, but make sure to include it.

wovano
  • 4,543
  • 5
  • 22
  • 49
2

I had a very similar problem using Windows 10.

So, initially installed Python 3.7 (adding to Path) and ensured pip was working

PS C:\foldername> pip

Then, ran the following commands to install virtualenv

PS C:\foldername> pip install --upgrade setuptools
PS C:\foldername> pip install ez_setup
PS C:\foldername> pip install virtualenv

Created a virtualenvs folder and got into it

PS C:\foldername> mkdir virtualenvs
PS C:\foldername> cd virtualenvs

Then, create the virtual environment molecoder

PS C:\foldername\virtualenvs> virtualenv molecoder
PS C:\foldername\virtualenvs> Set-ExecutionPolicy Unrestricted -Force

and tried to activate it

PS C:\foldername\virtualenvs> molecoder\Scripts\acivate

and got the following message

molecoder\Scripts\acivate : The module 'molecoder' could not be loaded. For more information, run 'Import-Module molecoder'. At line:1 char:1 + molecoder\Scripts\acivate + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (molecoder\Scripts\acivate:String) [], CommandNotFoundException + FullyQualifiedErrorId : CouldNotAutoLoadModule

In my case was because i wrote acivate instead of activate, so the following modification worked

PS C:\foldername\virtualenvs> molecoder\Scripts\activate

In your case you're trying to activate but activate is inside envname/Scripts , you're going to the wrong location.

To fix it you just need to run

PS C:\Users\piotr> bitcoin_notifications\Scripts\activate
molecoder
  • 423
  • 1
  • 7
  • 24