简体   繁体   中英

Trying to activate venv in PyCharm project with git

I've been trying for days to get a virtual environment for my Python project set up in PyCharm. I've seen a bunch of stuff online, but nothing seems to work for me.

Before I start anything, I run which python in my git bash terminal, which returns:

//asc/fs/homedir/<my_account>/pycharm/<repo_name>/Scripts/python

Then, when I try to officially activate the venv, I run source ./venv/Scripts/activate , which promptly fails with error:

bash: basename: command not found
()

After I do this, I lose the little tag at the end of my bash terminal dirpath that normally shows the current git branch I'm on. I don't see (venv) , which seems to be the expected behavior based on other stackoverflow posts. There is nothing appended to the current directory path of my terminal.

I can no longer run a number of standard bash commands. Running which python yields

bash: which: command not found
()

Is this some sort of PATH issue? Am I successfully activating the venv at all? (What is the '()' that shows up after every command?)

Supposedly this is an issue with pip on NETWORK drives.

I fixed the issue by moving my virtual environment to my native C: drive, and then went through the normal config process-

  • set my PyCharm Python interpreter to this NEW venv in my C: drive
  • updated my PyCharm run/debug configuration to use this new interpreter
  • restarted terminal
  • installed all the necessary deps with pip
  • Good to go! (now I can run pytest + other commands on this local project)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM