Replies: 2 comments 1 reply
-
If you made an article (on medium or any other platform) we can tag this on the course index. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Yes, I have a medium account. Would you suggest posting articles on medium instead? That might be better because I believe not many people are using the search function of the discussion board, judging by the repetitive nature of some posts. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For my Python projects I prefer to use a virtual environment. This helps to avoid version conflicts of installed packages and you can then also package the project nicely.
After setting up a Virtual Environment (venv) in a working directory, Virtual Studio Code will ask if you want to activate it for the area. Here you should click on "Yes", so that when you open the terminal the virtual environment is always activated automatically. This can be recognized by the fact that the name of the virtual environment appears in front of the prompt.
But if you want to install a Node JS module like Ganache in this environment, then Ganach will be installed, but the virtual environment doesn't know about it and
ganache --version
runs into an error.For such cases there is the module nodevenv. In the following I describe the (not quite trivial) setup procedure for Windows. A complete example including the setup of python venv is at the end of this article.
Open Powershell as administrator and change to the directory of your project.
Activate the Virtual Python Environment (mine is located in the project directory under
.venv
.>.venv\Scripts\Activate.ps1
Install the module nodeenv with
(.venv) >pip install nodeenv
Connect nodeenv with your virtual Python environment (might cause your antivirus to start scanning)
(.venv) >nodeenv -p
Check if the virtual environment is used for npm with
(.venv) >npm root -g
C:\Users\[...]\.venv\Scripts\node_modules
Check which modules are already installed (-g global here refers to the virtual environment)
`(.venv) >npm install -g ganache
Check again if Ganache was installed
Now Ganache should run in the virtual environment.
(.venv) >ganache
The whole flow without comments:
Beta Was this translation helpful? Give feedback.
All reactions