Always use a python virtual environment everywhereHow to install Err in a Python 3 virtual environment?How to install pyzmq for iPython Notebook in a Python 3 virtual environment?pyvenv vs venv vs python-virtualenv vs virtualenv and python 3How to ensure matplotlib in a Python 3 virtualenv uses the TkAgg backend?ubuntu not able to recognise python commandpython virtualenv: pip not workinginstalling Anaconda in virtual environment!Virtualenv Python versionHow do I create a Python virtual environment in the Ubuntu on Windows App using 'venv' rather than 'virtualenv'?
A bob hanging in an accelerating train moves backward. What is the force moving it backward?
How can you weaponize a thermos?
Is the choice of textbook really that important?
Why did we never simplify key signatures?
How can I pass a collection of exceptions as a root cause?
Who is Gail Gasram?
I can't understand how probability makes sense
Convention for inverted signal
Can Vice President Pence be impeached before President Trump?
What's a good use case for SELECT * in production code?
Why is it runway "1" instead of "01" in America?
Plane ticket price went down by 40% two weeks after I booked it. Is there anything I can do to get a refund?
Is Fox News not classified as a news channel?
Best fighting style for a pacifist
Are trigonometry functions Ratios or Distance?
Is Chika Ofili's method for checking divisibility for 7 a "new discovery" in math?
Is there a word/phrase that can describe playing a musical instrument in a casual way?
What is a recently obsolete computer storage device that would be significantly difficult to extract data from?
A Ukrainian idiom meaning "on one's last legs"
Not Renaming Child Directory When Parent Directory is Renamed
What does "Massage with salt" mean in a recipe?
What happens if a crew comply but do not repeat ATC instructions?
Why would a berry have a slow-acting poison?
Do Klingons have escape pods?
Always use a python virtual environment everywhere
How to install Err in a Python 3 virtual environment?How to install pyzmq for iPython Notebook in a Python 3 virtual environment?pyvenv vs venv vs python-virtualenv vs virtualenv and python 3How to ensure matplotlib in a Python 3 virtualenv uses the TkAgg backend?ubuntu not able to recognise python commandpython virtualenv: pip not workinginstalling Anaconda in virtual environment!Virtualenv Python versionHow do I create a Python virtual environment in the Ubuntu on Windows App using 'venv' rather than 'virtualenv'?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;
I am new to Ubuntu and Python virtualenv. Since I realized the importance of virtualenv, I'd like to use it by default whenever I run python(from installing packages) so that I don't need to run source bin/activate every time.
18.04 python3 virtualenv
add a comment
|
I am new to Ubuntu and Python virtualenv. Since I realized the importance of virtualenv, I'd like to use it by default whenever I run python(from installing packages) so that I don't need to run source bin/activate every time.
18.04 python3 virtualenv
add a comment
|
I am new to Ubuntu and Python virtualenv. Since I realized the importance of virtualenv, I'd like to use it by default whenever I run python(from installing packages) so that I don't need to run source bin/activate every time.
18.04 python3 virtualenv
I am new to Ubuntu and Python virtualenv. Since I realized the importance of virtualenv, I'd like to use it by default whenever I run python(from installing packages) so that I don't need to run source bin/activate every time.
18.04 python3 virtualenv
18.04 python3 virtualenv
asked Sep 9 at 6:36
James CasiaJames Casia
1031 bronze badge
1031 bronze badge
add a comment
|
add a comment
|
2 Answers
2
active
oldest
votes
if you are using virtualenv to create a virtual environment, it should be activated (manually or automatically) through running:
source PATH_TO_MY_ENV/bin/activate
However, when you don't want to type this every time and want to run it automatically by your desktop start-up, you should follow these three steps:
1. Create a shell script activate_my_env.sh and put the above
mentioned command in it:
# activate_my_env.sh
source PATH_TO_MY_ENV/bin/activate
2. Then, you need to change the permissions for activate_my_env.sh script to be
executable
(chmod +x):
chmod +x /path_to_your_file/activate_my_env.sh
NOTE: In this step you can also activate your environment without typing source my_env/bin/activate, but still need to run your script with this command:
./activate_my_env
3. Finally, in order to run the shell script automatically, you should set it to be run by start-up / reboot of your system:
A. edit contab file:
crontab -e
B. add the following line to this contab file:
@reboot /path_to_you_file/activate_my_env.sh
Reboot your system and you should have your virtual environment activated automatically, after every ubuntu startup.
More about Running Shell Script by Ubuntu Startup
add a comment
|
I think the easiest way is to install Anaconda or Miniconda. It creates a virtual environment named base and makes it the default. So whenever you fire up your terminal, you will have base activated. Everything you install using conda or pip will be installed in the base.
Now please note that you may still need to use virtual environments. For example, you may have a Django 2.0 project and a Django 1.0 project. Then you need to keep 2 different virtual environments (say venv1 and venv2) with Django 2.0 in the venv2 and Django 1.0 in venv1. Otherwise you will have dependency errors.
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1171877%2falways-use-a-python-virtual-environment-everywhere%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
if you are using virtualenv to create a virtual environment, it should be activated (manually or automatically) through running:
source PATH_TO_MY_ENV/bin/activate
However, when you don't want to type this every time and want to run it automatically by your desktop start-up, you should follow these three steps:
1. Create a shell script activate_my_env.sh and put the above
mentioned command in it:
# activate_my_env.sh
source PATH_TO_MY_ENV/bin/activate
2. Then, you need to change the permissions for activate_my_env.sh script to be
executable
(chmod +x):
chmod +x /path_to_your_file/activate_my_env.sh
NOTE: In this step you can also activate your environment without typing source my_env/bin/activate, but still need to run your script with this command:
./activate_my_env
3. Finally, in order to run the shell script automatically, you should set it to be run by start-up / reboot of your system:
A. edit contab file:
crontab -e
B. add the following line to this contab file:
@reboot /path_to_you_file/activate_my_env.sh
Reboot your system and you should have your virtual environment activated automatically, after every ubuntu startup.
More about Running Shell Script by Ubuntu Startup
add a comment
|
if you are using virtualenv to create a virtual environment, it should be activated (manually or automatically) through running:
source PATH_TO_MY_ENV/bin/activate
However, when you don't want to type this every time and want to run it automatically by your desktop start-up, you should follow these three steps:
1. Create a shell script activate_my_env.sh and put the above
mentioned command in it:
# activate_my_env.sh
source PATH_TO_MY_ENV/bin/activate
2. Then, you need to change the permissions for activate_my_env.sh script to be
executable
(chmod +x):
chmod +x /path_to_your_file/activate_my_env.sh
NOTE: In this step you can also activate your environment without typing source my_env/bin/activate, but still need to run your script with this command:
./activate_my_env
3. Finally, in order to run the shell script automatically, you should set it to be run by start-up / reboot of your system:
A. edit contab file:
crontab -e
B. add the following line to this contab file:
@reboot /path_to_you_file/activate_my_env.sh
Reboot your system and you should have your virtual environment activated automatically, after every ubuntu startup.
More about Running Shell Script by Ubuntu Startup
add a comment
|
if you are using virtualenv to create a virtual environment, it should be activated (manually or automatically) through running:
source PATH_TO_MY_ENV/bin/activate
However, when you don't want to type this every time and want to run it automatically by your desktop start-up, you should follow these three steps:
1. Create a shell script activate_my_env.sh and put the above
mentioned command in it:
# activate_my_env.sh
source PATH_TO_MY_ENV/bin/activate
2. Then, you need to change the permissions for activate_my_env.sh script to be
executable
(chmod +x):
chmod +x /path_to_your_file/activate_my_env.sh
NOTE: In this step you can also activate your environment without typing source my_env/bin/activate, but still need to run your script with this command:
./activate_my_env
3. Finally, in order to run the shell script automatically, you should set it to be run by start-up / reboot of your system:
A. edit contab file:
crontab -e
B. add the following line to this contab file:
@reboot /path_to_you_file/activate_my_env.sh
Reboot your system and you should have your virtual environment activated automatically, after every ubuntu startup.
More about Running Shell Script by Ubuntu Startup
if you are using virtualenv to create a virtual environment, it should be activated (manually or automatically) through running:
source PATH_TO_MY_ENV/bin/activate
However, when you don't want to type this every time and want to run it automatically by your desktop start-up, you should follow these three steps:
1. Create a shell script activate_my_env.sh and put the above
mentioned command in it:
# activate_my_env.sh
source PATH_TO_MY_ENV/bin/activate
2. Then, you need to change the permissions for activate_my_env.sh script to be
executable
(chmod +x):
chmod +x /path_to_your_file/activate_my_env.sh
NOTE: In this step you can also activate your environment without typing source my_env/bin/activate, but still need to run your script with this command:
./activate_my_env
3. Finally, in order to run the shell script automatically, you should set it to be run by start-up / reboot of your system:
A. edit contab file:
crontab -e
B. add the following line to this contab file:
@reboot /path_to_you_file/activate_my_env.sh
Reboot your system and you should have your virtual environment activated automatically, after every ubuntu startup.
More about Running Shell Script by Ubuntu Startup
edited Sep 19 at 9:48
answered Sep 18 at 19:10
Behzad SezarBehzad Sezar
263 bronze badges
263 bronze badges
add a comment
|
add a comment
|
I think the easiest way is to install Anaconda or Miniconda. It creates a virtual environment named base and makes it the default. So whenever you fire up your terminal, you will have base activated. Everything you install using conda or pip will be installed in the base.
Now please note that you may still need to use virtual environments. For example, you may have a Django 2.0 project and a Django 1.0 project. Then you need to keep 2 different virtual environments (say venv1 and venv2) with Django 2.0 in the venv2 and Django 1.0 in venv1. Otherwise you will have dependency errors.
add a comment
|
I think the easiest way is to install Anaconda or Miniconda. It creates a virtual environment named base and makes it the default. So whenever you fire up your terminal, you will have base activated. Everything you install using conda or pip will be installed in the base.
Now please note that you may still need to use virtual environments. For example, you may have a Django 2.0 project and a Django 1.0 project. Then you need to keep 2 different virtual environments (say venv1 and venv2) with Django 2.0 in the venv2 and Django 1.0 in venv1. Otherwise you will have dependency errors.
add a comment
|
I think the easiest way is to install Anaconda or Miniconda. It creates a virtual environment named base and makes it the default. So whenever you fire up your terminal, you will have base activated. Everything you install using conda or pip will be installed in the base.
Now please note that you may still need to use virtual environments. For example, you may have a Django 2.0 project and a Django 1.0 project. Then you need to keep 2 different virtual environments (say venv1 and venv2) with Django 2.0 in the venv2 and Django 1.0 in venv1. Otherwise you will have dependency errors.
I think the easiest way is to install Anaconda or Miniconda. It creates a virtual environment named base and makes it the default. So whenever you fire up your terminal, you will have base activated. Everything you install using conda or pip will be installed in the base.
Now please note that you may still need to use virtual environments. For example, you may have a Django 2.0 project and a Django 1.0 project. Then you need to keep 2 different virtual environments (say venv1 and venv2) with Django 2.0 in the venv2 and Django 1.0 in venv1. Otherwise you will have dependency errors.
answered Sep 9 at 7:00
Qazi Fahim FarhanQazi Fahim Farhan
374 bronze badges
374 bronze badges
add a comment
|
add a comment
|
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1171877%2falways-use-a-python-virtual-environment-everywhere%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown