I installed pipenv
using
$ pip3 install pipenv
which gives me the error ImportError: cannot import name 'main'
in order to solve this error I followed these instructionsudo python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall
now pip3
command is working on terminal.
now I install pipenv
using pip3 install pipenv
it installed succesfully but when i tried to execute pipenv
on termnal it gave me
pipenv: command not found
at this point pip3
also gives ImportError: cannot import name 'main' error
in order to solve this i followed these instruction
PYTHON_BIN_PATH="$(python3 -m site --user-base)/bin"
PATH="$PATH:$PYTHON_BIN_PATH"
at this, point pipenv
is working but pip3
is not working .
How can I make both pip3
and pipenv
work at the same time?
Also, it seems that I have messed up my pipenv setting now the virtual environment is created by default at /home/sysadmin
instead of the location i used to create virtual environment /home/sysadmin/Desktop/helloworld
The problem is due to overwriting the system-managed version of pip when installing pipenv. You performed the correct first step by getting your system-managed pip back in order:
sudo python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall
Once that is done, it is important to note that pipenv will likely not be able to be installed at the global level due to the pip conflict. You can install pipenv at the user level:
pip install --user pipenv
This should install pipenv at a user-level in /home/username/.local so that it does not conflict with the global version of pip. In my case, that still did not work after running the '--user' switch, so I ran the longer 'fix what I screwed up' command once more to prep the environment:
sudo python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall
and then did the following:
mkdir /home/username/.local
... if it doesn't already exist
export PYTHONUSERBASE=/home/username/.local
Make sure the export took (bit me once during this process):
echo $PYTHONUSERBASE
Then, I ran the pip install --user pipenv
and all was well. I could then run pipenv from the CLI and it did not overwrite the global/system-managed pip module. Of course, this is specific to the user so you want to make sure you install pipenv this way while working as the user you wish to use pipenv.
References:
https://pipenv.readthedocs.io/en/latest/diagnose/#no-module-named-module-name https://pipenv.readthedocs.io/en/latest/install/#pragmatic-installation-of-pipenv https://pip.pypa.io/en/stable/user_guide/#user-installs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With