Search code examples
pythonpippipenv

Adding python projects with pipenv


Ubuntu 16 and python 3.5.2 Trying to add some python scripts in a folder /opt/python_scripts Tons of SSL errors on any pip install so I upgraded pip to 19.2.1 The only way I could upgrade it was with

sudo python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip

didn't help still got SSL errors but at least seems to work anyway

I want to try and get in the habit of using python environments to isolate requirements etc. Following pipenv instructions... I made a python_scripts folder under opt and installed pipenv

/opt/python_scripts$ pip3 install pipenv

but

/opt/python_scripts$ pipenv shell
PermissionError: [Errno 13] Permission denied: 'Pipfile'
/opt/python_scripts$ sudo pipenv shell
sudo: pipenv: command not found

Assuming the correct thing to do is to add my scripts under the opt folder. How can I get pipenv to work under that folder?


Solution

  • Let's first make sure pyhon is correct installed do the following python3 -V assuming that it's properly installed you get the correct version no error's or warnings do this sudo apt install python3-pip once installed verify pip3 list if you have errors do the following pip3 install virtualenvwrapper You will have to add the command to source/usr/local/bin/virtualenvwrapper.sh to your shell startup so do the following

    nano .bashrc
    
    export WORKON_HOME=$HOME/.virtualenvs
    export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
    export PROJECT_HOME=$HOME/Devel
    source /usr/local/bin/virtualenvwrapper.sh
    

    now run this command source ~/.bashrc I hope now your up and running, if you real need to use the pipenv then do the following sudo apt-get install python3-venv then run this to verify pipenv shell

    Good lucky and happy coding.