Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python virtualenvwrapper
#1
I am reading a book called Python Automation Cookbook.

First thing it mentions is getting a virtual environment set up.

I installed Python virtualenvwrapper

But I am getting this message when I start Ubuntu and when I start bash:

Quote:/usr/bin/python: No module named virtualenvwrapper
virtualenvwrapper.sh: There was a problem running the initialization hooks.

If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is
set properly.

I have installed virtualenvwrapper:


Quote:pedro@pedro-512ssd:~$ pip3 install virtualenvwrapper

In

/home/pedro/.local/bin/

I have

virtualenvwrapper.sh, virtualenv and virtualenvwrapper_lazy.sh

What should I do to set the path right?

In /home/pedro/.profle I followed the instructions to add this:
Quote:export WORKON_HOME=~/.virtualenvs
source /home/pedro/.local/bin/virtualenvwrapper.sh

I also put the above in .bashrc

But I am still getting the error message. What should I do??

The virtual environment seems to be working:

Quote:pedro@pedro-512ssd:~$ source .virtualenvs/automation_cookbook/bin/activate
(automation_cookbook) pedro@pedro-512ssd:~$
Reply
#2
This should get you started with virtual enviroments
https://packaging.python.org/guides/inst...ironments/

Personally I would uninstall that package and use this. Only because I'm familiar with this one.
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#3
Python comes with virtual environment build in venv,so no need to install anything.
# Make
tom@tom:~$ python -m venv my_env

# Cd in
tom@tom:~$ cd my_env/

# Activate
tom@tom:~/my_env$ source bin/activate

# Test pip
(my_env) tom@tom:~/my_env$ pip -V
pip 19.2.3 from /home/tom/my_env/lib/python3.8/site-packages/pip (python 3.8)
Windows.
# Make
G:\code
λ python -m venv my_env

# Cd in
G:\code
λ cd my_env\

# Activate
G:\code\my_env
λ G:\code\my_env\Scripts\activate

# Test pip
(my_env) G:\code\my_env
λ pip -V
pip 20.0.1 from g:\code\my_env\lib\site-packages\pip (python 3.7)
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020