我必须在Windows服务器上运行Python脚本.我怎么知道我拥有哪个版本的Python,甚至真的很重要?我正在考虑更新到最新版本的Python.
我已经通过搜索并尝试了各种替代方案而没有成功,现在花了几天时间 - 让我发疯.
使用Python 2.5.2在Red Hat Linux上运行开始使用最新的Virtualenv但无法激活它,我发现某处建议需要早期版本,所以我使用了Virtualenv 1.6.4,因为它应该适用于Python 2.6.
[necrailk@server6 ~]$ python virtualenv-1.6.4/virtualenv.py virtual
New python executable in virtual/bin/python
Installing setuptools............done.
Installing pip...............done.
Run Code Online (Sandbox Code Playgroud)
[necrailk@server6 ~]$ cd virtual
[necrailk@server6 ~/virtual]$ dir
bin include lib
Run Code Online (Sandbox Code Playgroud)
[necrailk@server6 ~/virtual]$ . bin/activate
/bin/.: Permission denied.
Run Code Online (Sandbox Code Playgroud)
[necrailk@server6 ~/virtual]$ cd bin
[necrailk@server6 bin]$ ls -l
total 3160
-rw-r--r-- 1 necrailk biz12 2130 Jan 30 11:38 activate
-rw-r--r-- 1 necrailk biz12 1050 Jan 30 11:38 activate.csh
-rw-r--r-- 1 necrailk biz12 2869 Jan 30 11:38 …Run Code Online (Sandbox Code Playgroud) 我已经设置了PyCharm,创建了我的virtualenv(通过虚拟env命令,或者直接在PyCharm中),并将该环境激活为我的Interpreter.一切都很好.
但是,如果我使用"工具,打开终端"打开终端,提供的shell提示符不使用虚拟环境; 我仍然必须source ~/envs/someenv/bin/activate在该终端内使用它来激活它.
另一种方法是激活shell中的环境,并从该环境运行PyCharm.这是"可行的",但非常难看,如果我从PyCharm切换环境或项目,我就会遇到重大问题:我现在正在使用完全错误的环境.
是否有其他更简单的方法让"工具,开放式终端"自动激活虚拟环境?
我围绕我的项目创建了一个virtualenv,但是当我尝试激活它时我不能.它可能只是语法或文件夹位置,但我现在很难过.
你可以在下面看到,我创建了virtualenv并称之为venv.一切看起来都不错,然后我尝试通过运行来激活它source venv/bin/activate
我想它可能只与我的系统路径有关,但不知道该指向什么(我知道如何编辑路径).我在python 7/windows os,虚拟环境2.2.x
Processing dependencies for virtualenv Finished processing dependencies for virtualenv c:\testdjangoproj\mysite>virtualenv --no-site-packages venv The --no-site-packages flag is deprecated; it is now the default behavior. Using real prefix 'C:\\Program Files (x86)\\Python' New python executable in venv\Scripts\python.exe File venv\Lib\distutils\distutils.cfg exists with different content; not overwri ting Installing setuptools.................done. Installing pip...................done. c:\testdjangoproj\mysite>source venv/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. c:\testdjangoproj\mysite>source venv/bin/activate 'source' is not recognized …
基本上我似乎无法激活我创建的virtualenv环境.
我通过使用在Windows PowerShell中执行此操作
scripts\activate
Run Code Online (Sandbox Code Playgroud)
但得到一条错误信息
"无法加载,因为在此系统上禁用了脚本的执行".
这可能是因为我的计算机上没有管理员权限吗?
我一直试图修复,无法找到错误不断出现的原因.Pmin,Pmax,w,fi1和fi2都被赋予了有限值
guess=Pmin+(Pmax-Pmin)*((1-w**2)*fi1+(w**2)*fi2)
Run Code Online (Sandbox Code Playgroud)
当我从代码中删除此行时,在下一行代码中出现相同的错误,再次无缘无故我能想到
编辑:这是我所指的代码块:
def Psat(self, T):
pop= self.getPborder(T)
boolean=int(pop[0])
P1=pop[1]
P2=pop[2]
if boolean:
Pmin = float(min([P1, P2]))
Pmax = float(max([P1, P2]))
Tr=T/self.typeMolecule.Tc
w=0.5*(1+scipy.tanh((10**5)*(Tr-0.6)))
fi1=0.5*(1-scipy.tanh(8*((Tr**0.4)-1)))
fi2=0.460*scipy.sqrt(1-(Tr-0.566)**2/(0.434**2)+0.494
guess = Pmin+(Pmax-Pmin)*((1-w**2)*fi1+(w**2)*fi2) #error here
solution = scipy.optimize.newton(funcPsat,guess, args=(T,self))
Run Code Online (Sandbox Code Playgroud)