I am working to set up a django project on ec2 with an Ubuntu 14.4 LTS instance. I want to write my code using python 3 and django. I've been advised that the best way to do this is to use virtualenvwrapper. I tried:
ubuntu:~$ sudo pip3 install virtualenvwrapper
Successfully uninstalled six
Successfully installed virtualenvwrapper virtualenv virtualenv-clone stevedore argparse pbr six
Cleaning up...
ubuntu:~$ mkvirtualenv env1
mkvirtualenv: command not found
What am I doing wrong?
edit:
I followed your directions, logged out and logged back in:
/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'm suspecting that this is because I'm installing to python3 which is not the default python interpreter
From the documentation
Shell Startup File
Add three lines to your shell startup file
(.bashrc, .profile, etc.) to set the location where the virtual
environments should live, the location of your development project
directories, and the location of the script installed with this
package:
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh
In particular, sourcing the shell script above will allow you to run all of the virtualenvwrapper commands.
Related
I use Windows 10. I was trying to pip install Vectorbt but the installation could not have been finished because there was an error when numba and llvmlite were suppose to be installed. I was using Python 3.10 and read that there is a compatibility problem with it. So I uninstalled it and installed Python 3.8.7. Afterwards I made sure that the system variable is set on the proper Python path. I closed everything and even restarted the system but in the command line or the powershell terminal in VSC I get the error "No Python at" and the directory of the previous 3.10 installation.
The variable is set corectly (was set as an admin).
Any ideas?
Maybe something with the registry?
Thanks!
I can recommend you use virtual environments to manage python versions (you'll never look back), high level steps:
cd mydir
virtualenv .venv # creates a virtual env dev (or python3 -m venv .venv)
source .venv/bin/activate # activates the virtual env
pip install -r requirements.txt # installs the required dependencies
python -m pytest # runs the unit tests
More details in the docs: https://docs.python.org/3/library/venv.html
could you help me with followings.
paramiko 16.1.0 library is in [python default] /usr/local/lib/python2.7/site-packages
But I can not upgrade paramiko 16.1.0 library to current paramiko 2.8.0 library; so I had to download paramiko 2.8.0 library into my path /home/pylib
Please let me know how I can force python to use /home/pylib/paramiko [paramiko 2.8.0 library] in my python code
Note: for now I am stuck with Python 2.7;I can not update PYTHONPATH
It's good practice to use virtual environments to avoid conflicts like this.
What is a virtual environment?
A virtual environment is basically like creating a fresh installation of Python for only one project. This allows you to easily have two different versions of a library installed for different projects.
How do I use virtual environments?
Install the virtualenv package: pip2 install virtualenv
Go to the root of your project cd path/to/project/root
Create a virtualenv: virtualenv -p /usr/bin/python2 venv
Activate the environment: . venv/bin/activate
Install the package version you want: pip2 install paramiko==2.8.0
Run your program: python something.py
To exit the virtual environment use: deactivate
Next time you want to run your program make sure you activate the environment with . venv/bin/activate first. None of the other steps need to be repeated.
I'm setting up a new machine (OSX 10.12.6) and trying to get my python environment setup. I have installed both 2 and 3 with brew. The solutions described in other questions don't seem to help.
.zshrc looks like this:
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/projects
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
source /usr/local/bin/virtualenvwrapper.sh
Error I'm getting when I open a new shell:
/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.
The weird thing is that everything works fine - I can use mkvirtualenv just fine. But I don't want the error message and I don't get what is going on with my path? Please help!
I installed virtualenv and wrapper with pip and pip3
pip freeze:
pbr==3.1.1
six==1.10.0
stevedore==1.26.0
virtualenv==15.1.0
virtualenv-clone==0.2.6
virtualenvwrapper==4.8.1
$PATH:
/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
I am creating a Django App and stuck at virtualenv installation. I have seen this and tried to follow but it resulted in this everytime I tried something. Why can't it take python 3 for installing but this works virtualenv venv but it installs for python 2. What should I do?
virtualenv -p python3 venv
Running virtualenv with interpreter /home/oroborus/anaconda3/bin/python3
Using base prefix '/home/oroborus/anaconda3'
New python executable in venv/bin/python3
Also creating executable in venv/bin/python
venv/bin/python3: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory
ERROR: The executable venv/bin/python3 is not functioning
ERROR: It thinks sys.prefix is '/home/oroborus/PycharmProjects/test-app' (should be '/home/oroborus/PycharmProjects/test-app/venv')
ERROR: virtualenv is not compatible with this system or executable
Typing locate libpython3.5
locate libpython3.5
/home/oroborus/anaconda3/envs/tensorflow/lib/libpython3.5m.so
/home/oroborus/anaconda3/envs/tensorflow/lib/libpython3.5m.so.1.0
/home/oroborus/anaconda3/envs/tensorflow/lib/python3.5/config-3.5m/libpython3.5m.a
/home/oroborus/anaconda3/lib/libpython3.5m.so
/home/oroborus/anaconda3/lib/libpython3.5m.so.1.0
/home/oroborus/anaconda3/lib/python3.5/config-3.5m/libpython3.5m.a
/home/oroborus/anaconda3/pkgs/python-3.5.2-0/lib/libpython3.5m.so
/home/oroborus/anaconda3/pkgs/python-3.5.2-0/lib/libpython3.5m.so.1.0
/home/oroborus/anaconda3/pkgs/python-3.5.2-0/lib/python3.5/config-3.5m/libpython3.5m.a
In debian like distros python3-venv is available.
Install it using apt sudo apt-get install python3 python3-venv.
Then use it like that python3 -m venv yourvenvfoldername.
EDIT:
In this case anaconda is used, which has the replacement conda for both, pip and virtualenv. There is nice command comparison table available in the docs.
Creating a virtualenv with conda can be done like that:
conda create --name $ENVIRONMENT_NAME python
I am a beginner and read somewhere that we should always create virtual environments when working with Python. Therefore, I created a virtual environment using:
python -m virtualenv headlines
It copies all files with messages like
Using base prefix 'C:\\Program Files\\Python 3.5'
New python executable in C:\Users\Babu\headlines\Scripts\python.exe
Installing setuptools, pip, wheel...
Now, I want to install a module locally in this virtual environment using the following command:
python -m pip install feedparser
I think it is being installed in the Program Files Directory in Python 3.5 folder because the console shows:
copying build\lib\feedparser.py -> c:\program files\python 3.5\Lib\site-packages
error: could not create 'c:\program files\python 3.5\Lib\site-packages\feedparser.py': Permission denied
How can I resolve that?
I assume that you have already virtual environment folder successfully created.
First of all, you should be "inside" in your virtualenv in order to use it, thus for linux environments:
~$ source ${your_venv_folder_name}/bin/activate
will cause command line look like this
(venv)~$
Or for windows environments, like this:
python -m venv ${your_venv_folder_name}
According to this manual
python 3.4
If Python 3.4 is installed it is not necessary to install virtualenv
separately. Instead it is possible to use the venv module:
python < 3.4
virtualenv can be installed using the previously installed pip:
pip.exe install virtualenv
Now I see that you haven't enough permissions to install additional modules, so try to restart cmd terminal with administrator privileges according to this manual
Now then, with venv activated in current console and have sufficient privileges, it's should be easy to install modules from pip as usual.